Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
super().setUp()
# Populate the cache with three hits:
cache = CachedOrderedDict(
redis=self.redis,
key=self._KEY,
keys=('hit1', 'hit2', 'hit3'),
)
cache['hit1'] = 'value1'
cache['hit2'] = 'value2'
cache['hit3'] = 'value3'
# Instantiate the cache again with the three hits and three misses:
self.cache = CachedOrderedDict(
redis=self.redis,
key=self._KEY,
keys=('hit1', 'miss1', 'hit2', 'miss2', 'hit3', 'miss3'),
)
def test_setitem(self):
assert self.cache == collections.OrderedDict((
('hit1', 'value1'),
('miss1', CachedOrderedDict._SENTINEL),
('hit2', 'value2'),
('miss2', CachedOrderedDict._SENTINEL),
('hit3', 'value3'),
('miss3', CachedOrderedDict._SENTINEL),
))
assert self.cache._cache == {
'hit1': 'value1',
'hit2': 'value2',
'hit3': 'value3',
}
assert self.cache.misses() == {'miss1', 'miss2', 'miss3'}
self.cache['hit4'] = 'value4'
assert self.cache == collections.OrderedDict((
('hit1', 'value1'),
('miss1', CachedOrderedDict._SENTINEL),
def setUp(self):
super().setUp()
# Populate the cache with three hits:
cache = CachedOrderedDict(
redis=self.redis,
key=self._KEY,
keys=('hit1', 'hit2', 'hit3'),
)
cache['hit1'] = 'value1'
cache['hit2'] = 'value2'
cache['hit3'] = 'value3'
# Instantiate the cache again with the three hits and three misses:
self.cache = CachedOrderedDict(
redis=self.redis,
key=self._KEY,
keys=('hit1', 'miss1', 'hit2', 'miss2', 'hit3', 'miss3'),
)