def test_getStatistics(self): 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_timedCleanup(self): from time import sleep c = RAMCache() c.update(cleanupInterval=1, maxAge=2) lastCleanup = c._getStorage().lastCleanup sleep(2) c.set(42, "object", key={'foo': 'bar'}) # last cleanup should now be updated self.failUnless(lastCleanup < c._getStorage().lastCleanup)
def test_set(self): ob = ('path',) keywords = {"answer": 42} value = "true" c = RAMCache() c.requestVars = ('foo', 'bar') key = RAMCache._buildKey(keywords) c.set(value, ob, keywords) self.assertEqual(c._getStorage().getEntry(ob, key), value, "Not stored correctly")