Ejemplo n.º 1
0
    def test_merge_four_sets(self):
        crdt1 = GSet()
        crdt2 = GSet()
        crdt3 = GSet()
        crdt4 = GSet()
        crdt1.add('A')
        crdt2.add('B')
        crdt3.add('C')
        crdt4.add('D')

        crdt1 = crdt1.merge(crdt2)
        crdt1 = crdt1.merge(crdt3)
        crdt1 = crdt1.merge(crdt4)

        self.assertEqual(list(crdt1.values()), ['A', 'B', 'C', 'D'])
Ejemplo n.º 2
0
 def test_merge_same_set(self):
     crdt1 = GSet()
     crdt2 = GSet()
     crdt1.add('A')
     crdt2.add('A')
     crdt1 = crdt1.merge(crdt2)
     self.assertEqual(list(crdt1.values()), ['A'])
Ejemplo n.º 3
0
 def test_merge(self):
     crdt1 = GSet()
     crdt2 = GSet()
     crdt1.add('A')
     crdt2.add('B')
     crdt2.add('C')
     crdt1 = crdt1.merge(crdt2)
     self.assertEqual(list(crdt1.values()), ['A', 'B', 'C'])
Ejemplo n.º 4
0
 def test_no_overwrite_on_merge(self):
     a = OrderedSet()
     a.add('A')
     a.add('Z')
     a.add('B')
     print(a)
     crdt1 = GSet()
     crdt2 = GSet()
     crdt1.add('A')
     crdt2.add('B')
     crdt1 = crdt1.merge(crdt2)
     print(crdt1._payload)
     crdt1.add('AA')
     crdt2.add('BB')
     crdt1 = crdt1.merge(crdt2)
     print(crdt1._payload)
     self.assertEqual(crdt1._payload, ['A', 'B', 'AA', 'BB'])
     self.assertEqual(crdt2._payload, ['B', 'BB'])