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_getValue_default(self): store = MemoryStore() result = yield store.getValue('foo', 'default') self.assertEqual(result, 'default')
def test_KeyError(self): store = MemoryStore() 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)