Exemple #1
0
    def test_order(self):
        t1 = time()
        a = _lamportinfo(133, t1, 'A', 'obj')
        b = _lamportinfo(140, t1, 'A', 'obj')
        self.assertTrue(a.__getnewargs__())
        self.assertEqual(a.clock, 133)
        self.assertEqual(a.timestamp, t1)
        self.assertEqual(a.id, 'A')
        self.assertEqual(a.obj, 'obj')
        self.assertTrue(
            a <= b,
        )
        self.assertTrue(
            b >= a,
        )

        self.assertEqual(
            _lamportinfo(134, time(), 'A', 'obj').__lt__(tuple()),
            NotImplemented,
        )
        self.assertGreater(
            _lamportinfo(134, time(), 'A', 'obj'),
            _lamportinfo(133, time(), 'A', 'obj'),
        )
        self.assertGreater(
            _lamportinfo(134, t1, 'B', 'obj'),
            _lamportinfo(134, t1, 'A', 'obj'),
        )

        self.assertGreater(
            _lamportinfo(None, time(), 'B', 'obj'),
            _lamportinfo(None, t1, 'A', 'obj'),
        )
Exemple #2
0
    def test_order(self):
        t1 = time()
        a = _lamportinfo(133, t1, 'A', 'obj')
        b = _lamportinfo(140, t1, 'A', 'obj')
        self.assertTrue(a.__getnewargs__())
        self.assertEqual(a.clock, 133)
        self.assertEqual(a.timestamp, t1)
        self.assertEqual(a.id, 'A')
        self.assertEqual(a.obj, 'obj')
        self.assertTrue(a <= b, )
        self.assertTrue(b >= a, )

        self.assertEqual(
            _lamportinfo(134, time(), 'A', 'obj').__lt__(tuple()),
            NotImplemented,
        )
        self.assertGreater(
            _lamportinfo(134, time(), 'A', 'obj'),
            _lamportinfo(133, time(), 'A', 'obj'),
        )
        self.assertGreater(
            _lamportinfo(134, t1, 'B', 'obj'),
            _lamportinfo(134, t1, 'A', 'obj'),
        )

        self.assertGreater(
            _lamportinfo(None, time(), 'B', 'obj'),
            _lamportinfo(None, t1, 'A', 'obj'),
        )
Exemple #3
0
 def test_pickleable(self):
     x = _lamportinfo(133, time(), 'id', 'obj')
     self.assertEqual(pickle.loads(pickle.dumps(x)), tuple(x))
Exemple #4
0
 def test_repr(self):
     x = _lamportinfo(133, time(), 'id', Mock())
     self.assertTrue(repr(x))
Exemple #5
0
 def test_pickleable(self):
     x = _lamportinfo(133, time(), 'id', 'obj')
     self.assertEqual(pickle.loads(pickle.dumps(x)), tuple(x))
Exemple #6
0
 def test_repr(self):
     x = _lamportinfo(133, time(), 'id', Mock())
     self.assertTrue(repr(x))