def test_sub(self): gs1 = gtid.GTIDSet('3E11FA47-71CA-11E1-9E33-C80AA9429562:1-23:27') self.assertEqual(self.gtid_set - gs1, gtid.GTIDSet('')) gs2 = gtid.GTIDSet('3E11FA47-71CA-11E1-9E33-C80AA9429562:2-5:21:24-29') self.assertEqual( self.gtid_set - gs2, gtid.GTIDSet('3E11FA47-71CA-11E1-9E33-C80AA9429562:1:6-20:22-23'))
def test_trx_count(self): self.assertEqual(self.gtid_set.count(), 24) gs1 = gtid.GTIDSet("""84d15910-b6a4-11e4-af2c-080027880ca6:1, 966073f3-b6a4-11e4-af2c-080027880ca6:1-29""") self.assertEqual(gs1.count(), 30) gs2 = gtid.GTIDSet('') self.assertEqual(gs2.count(), 0)
def test_base(self): self.assertEqual(self.gtid_set['3E11FA47-71CA-11E1-9E33-C80AA9429562'], gtid.GTIDRangeList('1-23:27')) empty = gtid.GTIDSet('') self.assertEqual(empty.sets, {}) self.assertFalse(empty) self.assertEqual( gtid.GTIDSet('4d15910-b6a4-11e4-af2c-080027880ca6:1') ['4d15910-b6a4-11e4-af2c-080027880ca6'], gtid.GTIDRangeList('1'))
def test_add(self): gs1 = gtid.GTIDSet('4d15910-b6a4-11e4-af2c-080027880ca6:1') self.assertEqual( gs1 + self.gtid_set, gtid.GTIDSet("""3E11FA47-71CA-11E1-9E33-C80AA9429562:1-23:27, 4d15910-b6a4-11e4-af2c-080027880ca6:1""")) gs2 = gtid.GTIDSet('3E11FA47-71CA-11E1-9E33-C80AA9429562:24-26:28') self.assertEqual( gs2 + self.gtid_set, gtid.GTIDSet('3E11FA47-71CA-11E1-9E33-C80AA9429562:1-28'))
def test_multiline(self): gtid_set = gtid.GTIDSet("""84d15910-b6a4-11e4-af2c-080027880ca6:1, 966073f3-b6a4-11e4-af2c-080027880ca6:1-29""") self.assertEqual(sorted(gtid_set.sets.keys()), [ '84d15910-b6a4-11e4-af2c-080027880ca6', '966073f3-b6a4-11e4-af2c-080027880ca6' ])
def test_str(self): self.assertEqual(str(self.gtid_set), '3E11FA47-71CA-11E1-9E33-C80AA9429562:1-23:27') gtid_set = gtid.GTIDSet("""84d15910-b6a4-11e4-af2c-080027880ca6:1, 966073f3-b6a4-11e4-af2c-080027880ca6:1-29""") self.assertEqual( str(gtid_set), """84d15910-b6a4-11e4-af2c-080027880ca6:1, 966073f3-b6a4-11e4-af2c-080027880ca6:1-29""")
def test_contains(self): self.assertIn(gtid.GTIDRange(2, 98), self.gl1) self.assertIn(gtid.GTIDRange(141), self.gl1) self.assertIn(gtid.GTIDRange(145, 197), self.gl1) self.assertNotIn(gtid.GTIDRange(144, 197), self.gl1) self.assertNotIn(gtid.GTIDRange(142), self.gl1) self.assertIn(gtid.GTIDRangeList('2-98:141'), self.gl1) self.assertIn(gtid.GTIDRangeList('141'), self.gl1) self.assertIn(gtid.GTIDRangeList('1-139:141:145-197'), self.gl1) self.assertNotIn(gtid.GTIDRangeList('1-139:141-142:145-197'), self.gl1) self.assertRaises( TypeError, lambda: gtid.GTIDSet( '3E11FA47-71CA-11E1-9E33-C80AA9429562:1-23:27') in self.gl1) self.assertRaises(TypeError, lambda: (1, 47) in self.gl1)
def setUp(self): self.gtid_set = gtid.GTIDSet( '3E11FA47-71CA-11E1-9E33-C80AA9429562:1-23:27')