inveniosoftware / pytest-invenio

Pytest fixtures for Invenio.
https://pytest-invenio.readthedocs.io
Other
3 stars 22 forks source link

Add invenio-cache (Redis) fixture #30

Open slint opened 5 years ago

slint commented 5 years ago

It would be useful to have invenio-cache (or Redis) fixtures to be able to:

Another interesting alternative is specifying a custom CACHE_KEY_PREFIX for testing (e.g. 'tests::cache::') and clear only this one.

ppanero commented 3 years ago

See https://github.com/inveniosoftware/invenio-records-resources/pull/191/files#diff-0ba313cb2999f359508cf4f109393ff1549358fb857cd9c3620266ad7994a627R71 for reference

ppanero commented 2 years ago

An ad-hoc fixture has been placed in invenio-record-resources, invenio-vocabularies and invenio-rdm-records, remove from there when fixing this issue:

@pytest.fixture()
def cache():
    """Empty cache."""
    try:
        current_cache.clear()
        yield current_cache
    finally:
        current_cache.clear()