def test_cache_put(self, CacheEntry, CacheStats):
        store = MagicMock()

        c = Cache(store=MagicMock(return_value=store))
        c.put('foo', 'Value Of Foo', new=True)

        CacheEntry.assert_called_once_with('Value Of Foo')

        store.__setitem__.assert_called_once_with('foo',
            CacheEntry.return_value)
        CacheStats.return_value.put.assert_called_once_with(new=True)
Beispiel #2
0
    def test_cache_put(self, CacheEntry, CacheStats):
        store = MagicMock()

        c = Cache(store=MagicMock(return_value=store))
        c.put('foo', 'Value Of Foo', new=True)

        CacheEntry.assert_called_once_with('Value Of Foo')

        store.__setitem__.assert_called_once_with('foo',
            CacheEntry.return_value)
        CacheStats.return_value.put.assert_called_once_with(new=True)
Beispiel #3
0
 def test_cache_max_entries(self, CacheStats):
     cache = Cache(store=MemoryStore, store_opts={'max_entries': 2})
     for i in range(1,10):
         cache.put(i, i)
     self.assertEqual(2, len(cache.store))
     self.assertEqual(list(cache.store.store.keys()), [8,9])