class TestCacheDecorator(unittest.TestCase, SimpleKVTest): def setUp(self): self.backing_store = DictStore() self.cache = DictStore() self.store = CacheDecorator(self.cache, self.backing_store) def test_works_when_cache_loses_key(self): self.store.put('keya', 'valuea') self.store.put('keyb', 'valueb') self.assertEqual('valuea', self.store.get('keya')) self.assertEqual('valueb', self.store.get('keyb')) del self.store.cache.d['keya'] self.assertEqual('valuea', self.store.get('keya')) self.assertEqual('valueb', self.store.get('keyb'))
def store(self, front_store, backing_store): return CacheDecorator(front_store, backing_store)
def setUp(self): self.backing_store = DictStore() self.cache = DictStore() self.store = CacheDecorator(self.cache, self.backing_store)