Exemple #1
0
 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)
Exemple #2
0
 def test_getValue_default(self):
     store = MemoryStore()
     result = yield store.getValue('foo', 'default')
     self.assertEqual(result, 'default')
Exemple #3
0
 def test_KeyError(self):
     store = MemoryStore()
     self.assertFailure(store.getValue('foo'), KeyError)
Exemple #4
0
 def test_rmValue(self):
     store = MemoryStore()
     yield store.setValue('foo', 5)
     yield store.rmValue('foo')
     yield self.assertFailure(store.getValue('foo'), KeyError)
Exemple #5
0
 def test_basic(self):
     store = MemoryStore()
     yield store.setValue('foo', 5)
     value = yield store.getValue('foo')
     self.assertEqual(value, 5)