def test_getStatistics(self): from zope.app.cache.ram import RAMCache c = RAMCache() c.set(42, "object", key={'foo': 'bar'}) c.set(43, "object", key={'foo': 'bar'}) c.query("object") c.query("object", key={'foo': 'bar'}) r1 = c._getStorage().getStatistics() r2 = c.getStatistics() self.assertEqual(r1, r2, "see Storage.getStatistics() tests")
def test_query(self): from zope.app.cache.ram import RAMCache ob = ('aaa',) keywords = {"answer": 42} value = "true" c = RAMCache() key = RAMCache._buildKey(keywords) c._getStorage().setEntry(ob, key, value) self.assertEqual(c.query(ob, keywords), value, "incorrect value") self.assertEqual(c.query(ob, None), None, "defaults incorrect") self.assertEqual(c.query(ob, {"answer": 2}, default="bummer"), "bummer", "default doesn't work")