def test_remove(cache): '''Remove item from cache.''' cache.set('key', 'value') cache.remove('key') with pytest.raises(KeyError): cache.get('key')
def test_set(cache): '''Set item in cache.''' with pytest.raises(KeyError): cache.get('key') cache.set('key', 'value') assert cache.get('key') == 'value'
def test_layered_cache_propagates_value_on_get(): '''Layered cache propagates value on get.''' caches = [ ftrack_api.cache.MemoryCache(), ftrack_api.cache.MemoryCache(), ftrack_api.cache.MemoryCache() ] cache = ftrack_api.cache.LayeredCache(caches) # Set item on second level cache only. caches[1].set('key', 'value') # Retrieving key via layered cache should propagate it automatically to # higher level caches only. assert cache.get('key') == 'value' assert caches[0].get('key') == 'value' with pytest.raises(KeyError): caches[2].get('key')
def test_get_missing_key(cache): '''Fail to retrieve missing item from cache.''' with pytest.raises(KeyError): cache.get('key')
def test_get(cache): '''Retrieve item from cache.''' cache.set('key', 'value') assert cache.get('key') == 'value'