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