import pytest from data.cache import InMemoryDataModelCache, NoopDataModelCache from data.cache.cache_key import CacheKey @pytest.mark.parametrize('cache_type', [ (NoopDataModelCache), (InMemoryDataModelCache), ]) def test_caching(cache_type): key = CacheKey('foo', '60m') cache = cache_type() # Perform two retrievals, and make sure both return. assert cache.retrieve(key, lambda: 1234) == 1234 assert cache.retrieve(key, lambda: 1234) == 1234