Skip to content

Commit

Permalink
fixtures: add fixture for cache_uri
Browse files Browse the repository at this point in the history
* this provides the option to make the cache_uri configurable on tests
  • Loading branch information
utnapischtim authored and slint committed Mar 7, 2025
1 parent 59065c5 commit e8fcdb1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pytest_invenio/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This file is part of pytest-invenio.
# Copyright (C) 2017-2024 CERN.
# Copyright (C) 2018 Esteban J. G. Garbancho.
# Copyright (C) 2024 Graz University of Technology.
# Copyright (C) 2024-2025 Graz University of Technology.
#
# pytest-invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -69,6 +69,15 @@ def instance_path():
shutil.rmtree(path)


@pytest.fixture(scope="module")
def cache_uri():
"""Cache uri."""
if "CACHE_REDIS_URL" in os.environ:
yield os.environ["CACHE_REDIS_URL"]
else:
yield None


@pytest.fixture(scope="module")
def db_uri(instance_path):
"""Database URI (defaults to an SQLite datbase in the instance path).
Expand Down
2 changes: 2 additions & 0 deletions pytest_invenio/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of pytest-invenio.
# Copyright (C) 2017-2018 CERN.
# Copyright (C) 2018 Northwestern University, Feinberg School of Medicine,
# Copyright (C) 2025 Graz University of Technology.
# Galter Health Sciences Library.
#
# pytest-invenio is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -33,6 +34,7 @@
broker_uri,
browser,
bucket_from_dir,
cache_uri,
celery_config,
celery_config_ext,
cli_runner,
Expand Down

0 comments on commit e8fcdb1

Please sign in to comment.