1424
1424
self.assertMergeOrder(['rev3', 'rev1'], graph, 'rev4', ['rev1', 'rev3'])
1427
class TestFindDescendants(TestGraphBase):
1429
def test_find_descendants_rev1_rev3(self):
1430
graph = self.make_graph(ancestry_1)
1431
descendants = graph.find_descendants('rev1', 'rev3')
1432
self.assertEqual(set(['rev1', 'rev2a', 'rev3']), descendants)
1434
def test_find_descendants_rev1_rev4(self):
1435
graph = self.make_graph(ancestry_1)
1436
descendants = graph.find_descendants('rev1', 'rev4')
1437
self.assertEqual(set(['rev1', 'rev2a', 'rev2b', 'rev3', 'rev4']),
1440
def test_find_descendants_rev2a_rev4(self):
1441
graph = self.make_graph(ancestry_1)
1442
descendants = graph.find_descendants('rev2a', 'rev4')
1443
self.assertEqual(set(['rev2a', 'rev3', 'rev4']), descendants)
1445
class TestFindLefthandMerger(TestGraphBase):
1447
def check_merger(self, result, ancestry, merged, tip):
1448
graph = self.make_graph(ancestry)
1449
self.assertEqual(result, graph.find_lefthand_merger(merged, tip))
1451
def test_find_lefthand_merger_rev2b(self):
1452
self.check_merger('rev4', ancestry_1, 'rev2b', 'rev4')
1454
def test_find_lefthand_merger_rev2a(self):
1455
self.check_merger('rev2a', ancestry_1, 'rev2a', 'rev4')
1457
def test_find_lefthand_merger_rev4(self):
1458
self.check_merger(None, ancestry_1, 'rev4', 'rev2a')
1460
def test_find_lefthand_merger_f(self):
1461
self.check_merger('i', complex_shortcut, 'f', 'm')
1463
def test_find_lefthand_merger_g(self):
1464
self.check_merger('i', complex_shortcut, 'g', 'm')
1466
def test_find_lefthand_merger_h(self):
1467
self.check_merger('n', complex_shortcut, 'h', 'n')
1470
class TestGetChildMap(TestGraphBase):
1472
def test_get_child_map(self):
1473
graph = self.make_graph(ancestry_1)
1474
child_map = graph.get_child_map(['rev4', 'rev3', 'rev2a', 'rev2b'])
1475
self.assertEqual({'rev1': ['rev2a', 'rev2b'],
1482
1427
class TestCachingParentsProvider(tests.TestCase):
1483
1428
"""These tests run with: