~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_graph.py

  • Committer: John Arbash Meinel
  • Date: 2010-08-30 21:23:49 UTC
  • mto: This revision was merged to the branch mainline in revision 5398.
  • Revision ID: john@arbash-meinel.com-20100830212349-figt9yz2cic6hy68
Remove the 'false' invocation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2007-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
526
526
        graph = self.make_graph(history_shortcut)
527
527
        self.assertEqual(set(['rev2b']), graph.find_lca('rev3a', 'rev3b'))
528
528
 
 
529
    def test_lefthand_distance_smoke(self):
 
530
        """A simple does it work test for graph.lefthand_distance(keys)."""
 
531
        graph = self.make_graph(history_shortcut)
 
532
        distance_graph = graph.find_lefthand_distances(['rev3b', 'rev2a'])
 
533
        self.assertEqual({'rev2a': 2, 'rev3b': 3}, distance_graph)
 
534
 
 
535
    def test_lefthand_distance_ghosts(self):
 
536
        """A simple does it work test for graph.lefthand_distance(keys)."""
 
537
        nodes = {'nonghost':[NULL_REVISION], 'toghost':['ghost']}
 
538
        graph = self.make_graph(nodes)
 
539
        distance_graph = graph.find_lefthand_distances(['nonghost', 'toghost'])
 
540
        self.assertEqual({'nonghost': 1, 'toghost': -1}, distance_graph)
 
541
 
529
542
    def test_recursive_unique_lca(self):
530
543
        """Test finding a unique least common ancestor.
531
544
 
1569
1582
        self.assertCollapsed(d, d)
1570
1583
 
1571
1584
 
 
1585
class TestGraphThunkIdsToKeys(tests.TestCase):
 
1586
 
 
1587
    def test_heads(self):
 
1588
        # A
 
1589
        # |\
 
1590
        # B C
 
1591
        # |/
 
1592
        # D
 
1593
        d = {('D',): [('B',), ('C',)], ('C',):[('A',)],
 
1594
             ('B',): [('A',)], ('A',): []}
 
1595
        g = _mod_graph.Graph(_mod_graph.DictParentsProvider(d))
 
1596
        graph_thunk = _mod_graph.GraphThunkIdsToKeys(g)
 
1597
        self.assertEqual(['D'], sorted(graph_thunk.heads(['D', 'A'])))
 
1598
        self.assertEqual(['D'], sorted(graph_thunk.heads(['D', 'B'])))
 
1599
        self.assertEqual(['D'], sorted(graph_thunk.heads(['D', 'C'])))
 
1600
        self.assertEqual(['B', 'C'], sorted(graph_thunk.heads(['B', 'C'])))
 
1601
 
 
1602
 
1572
1603
class TestPendingAncestryResultGetKeys(TestCaseWithMemoryTransport):
1573
1604
    """Tests for bzrlib.graph.PendingAncestryResult."""
1574
1605