Ejemplo n.º 1
0
 def test_merge_items(self):
     broker1 = AccountBroker(':memory:', account='a')
     broker1.initialize(Timestamp('1').internal)
     broker2 = AccountBroker(':memory:', account='a')
     broker2.initialize(Timestamp('1').internal)
     broker1.put_container('a',
                           Timestamp(1).internal, 0, 0, 0,
                           POLICIES.default.idx)
     broker1.put_container('b',
                           Timestamp(2).internal, 0, 0, 0,
                           POLICIES.default.idx)
     id = broker1.get_info()['id']
     broker2.merge_items(
         broker1.get_items_since(broker2.get_sync(id), 1000), id)
     items = broker2.get_items_since(-1, 1000)
     self.assertEqual(len(items), 2)
     self.assertEqual(['a', 'b'], sorted([rec['name'] for rec in items]))
     broker1.put_container('c',
                           Timestamp(3).internal, 0, 0, 0,
                           POLICIES.default.idx)
     broker2.merge_items(
         broker1.get_items_since(broker2.get_sync(id), 1000), id)
     items = broker2.get_items_since(-1, 1000)
     self.assertEqual(len(items), 3)
     self.assertEqual(['a', 'b', 'c'],
                      sorted([rec['name'] for rec in items]))
Ejemplo n.º 2
0
 def test_merge_items(self):
     broker1 = AccountBroker(':memory:', account='a')
     broker1.initialize(normalize_timestamp('1'))
     broker2 = AccountBroker(':memory:', account='a')
     broker2.initialize(normalize_timestamp('1'))
     broker1.put_container('a', normalize_timestamp(1), 0, 0, 0)
     broker1.put_container('b', normalize_timestamp(2), 0, 0, 0)
     id = broker1.get_info()['id']
     broker2.merge_items(broker1.get_items_since(
         broker2.get_sync(id), 1000), id)
     items = broker2.get_items_since(-1, 1000)
     self.assertEqual(len(items), 2)
     self.assertEqual(['a', 'b'], sorted([rec['name'] for rec in items]))
     broker1.put_container('c', normalize_timestamp(3), 0, 0, 0)
     broker2.merge_items(broker1.get_items_since(
         broker2.get_sync(id), 1000), id)
     items = broker2.get_items_since(-1, 1000)
     self.assertEqual(len(items), 3)
     self.assertEqual(['a', 'b', 'c'],
                      sorted([rec['name'] for rec in items]))
Ejemplo n.º 3
0
 def test_merge_items(self):
     broker1 = AccountBroker(':memory:', account='a')
     broker1.initialize(normalize_timestamp('1'))
     broker2 = AccountBroker(':memory:', account='a')
     broker2.initialize(normalize_timestamp('1'))
     broker1.put_container('a', normalize_timestamp(1), 0, 0, 0)
     broker1.put_container('b', normalize_timestamp(2), 0, 0, 0)
     id = broker1.get_info()['id']
     broker2.merge_items(
         broker1.get_items_since(broker2.get_sync(id), 1000), id)
     items = broker2.get_items_since(-1, 1000)
     self.assertEquals(len(items), 2)
     self.assertEquals(['a', 'b'], sorted([rec['name'] for rec in items]))
     broker1.put_container('c', normalize_timestamp(3), 0, 0, 0)
     broker2.merge_items(
         broker1.get_items_since(broker2.get_sync(id), 1000), id)
     items = broker2.get_items_since(-1, 1000)
     self.assertEquals(len(items), 3)
     self.assertEquals(['a', 'b', 'c'],
                       sorted([rec['name'] for rec in items]))