Exemplo n.º 1
0
    def test_merge(self):
        a = Counter(value=5)
        b = Counter(value=5)

        b.increment(3)
        b.increment(2)
        a.increment(2)

        c = Counter.merge(a, b)

        self.assertEqual(c.current, 12)
        self.assertEqual(c._increment, 7)
        self.assertEqual(c._vclock, 3)
        self.assertTrue(c.isdirty())
        self.assertEqual(c.mutation(), {'increment': 7})
Exemplo n.º 2
0
    def test_fail_merge(self):
        a = Counter(value=5)
        b = Counter(value=7)

        with self.assertRaises(ValueError):
            Counter.merge(a, b)