Esempio n. 1
0
 def testBuffer(self):
     key = 'foo'
     data = 'bar'
     store = Store(filepath = self.tempfile())
     store.open()
     timestamp = timestamper.now()
     store.set(key, timestamp, buffer(data))
     self.assertEqual(store.count(), 1)
     assert store.get(key) == (timestamp, data)
Esempio n. 2
0
 def testStore(self):
     store = Store(filepath = self.tempfile())
     store.open()
     timestamp = timestamper.now()
     store.set("foo", timestamp, "bar")
     self.assertEqual(store.count(), 1)
     self.assertEqual(store.get("foo"), (timestamp, "bar"))
     self.assertEqual(store.get("loo"), (None, None))
     store.close()
     store.open()
     self.assertEqual(store.get("foo"), (timestamp, "bar"))
     self.assertEqual(store.count(), 1)
     store.remove("foo")
     self.assertEqual(store.count(), 0)
     self.assertEqual(store.get("foo"), (None, None))
     store.close()
Esempio n. 3
0
 def testTransaction(self):
     store = Store(filepath = self.tempfile(), auto_commit_interval=0)
     store.open()
     store.begin()
     timestamp = timestamper.now()
     store.set('foo', timestamp, 'foo')
     store.abort()
     store.close()
     store.open()
     self.assertEqual(store.get('foo'), (None, None))
     store.begin()
     store.set('bar', timestamp, 'bar')
     self.assertEqual(store.count(), 1)
     self.assertEqual(store.get('bar'), (timestamp, 'bar'))
     store.commit()
     self.assertEqual(store.get('bar'), (timestamp, 'bar'))
     self.assertEqual(store.count(), 1)
     store.close()
     store.open()
     self.assertEqual(store.count(), 1)
     self.assertEqual(store.get('bar'), (timestamp, 'bar'))
 def testPersistence(self):
     files = [
         'test/local_cluster.yaml',
         'test/migration_1.yaml',
         'test/migration_2.yaml',
         'test/migration_3.yaml',
         'examples/cluster.yaml',
         'examples/local_cluster.yaml',
         'examples/standalone.yaml'
     ]
     for f in files:
         configuration_directory = self.tempdir()
         cache = ConfigurationCache(configuration_directory, 'test')
         filepath = paths.path(f)
         cfg = configuration.try_load_file(filepath)
         for i in xrange(0, 10):
             cfg.timestamp = timestamper.now()
             cache.cache_configuration(cfg)
             read_configuration = cache.get_configuration()
             self.assertEqual(read_configuration.representation(), cfg.representation())
             self.assertEqual(read_configuration.timestamp, cfg.timestamp)