def test_exists(self): """ You can ask if a key exists. """ store = MemoryStore() exists = yield store.exists('foo') self.assertEqual(exists, False) yield store.setValue('foo', 'bar') exists = yield store.exists('foo') self.assertEqual(exists, True)
def test_expire(self): """ You can cause keys to expire. """ clock = task.Clock() store = MemoryStore(clock=clock) yield store.setValue('foo', 'bar') yield store.expire('foo', 50) clock.advance(49) result = yield store.getValue('foo') self.assertEqual(result, 'bar') clock.advance(1) yield self.assertFailure(store.getValue('foo'), KeyError)
def test_rmValue(self): store = MemoryStore() yield store.setValue('foo', 5) yield store.rmValue('foo') yield self.assertFailure(store.getValue('foo'), KeyError)
def test_basic(self): store = MemoryStore() yield store.setValue('foo', 5) value = yield store.getValue('foo') self.assertEqual(value, 5)