~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__known_graph.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-09-07 14:55:17 UTC
  • mfrom: (4676.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090907145517-70waesydou0uk4tk
(garyvdm) Add get_parent_keys,
        and get_child_keys methods to KnownGraph

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
 
100
100
    def test_children_ancestry1(self):
101
101
        graph = self.make_known_graph(test_graph.ancestry_1)
102
 
        self.assertEqual(['rev1'], graph._nodes[NULL_REVISION].child_keys)
 
102
        self.assertEqual(['rev1'], graph.get_child_keys(NULL_REVISION))
103
103
        self.assertEqual(['rev2a', 'rev2b'],
104
 
                         sorted(graph._nodes['rev1'].child_keys))
105
 
        self.assertEqual(['rev3'], sorted(graph._nodes['rev2a'].child_keys))
106
 
        self.assertEqual(['rev4'], sorted(graph._nodes['rev3'].child_keys))
107
 
        self.assertEqual(['rev4'], sorted(graph._nodes['rev2b'].child_keys))
 
104
                         sorted(graph.get_child_keys('rev1')))
 
105
        self.assertEqual(['rev3'], graph.get_child_keys('rev2a'))
 
106
        self.assertEqual(['rev4'], graph.get_child_keys('rev3'))
 
107
        self.assertEqual(['rev4'], graph.get_child_keys('rev2b'))
 
108
        self.assertRaises(KeyError, graph.get_child_keys, 'not_in_graph')
 
109
 
 
110
    def test_parent_ancestry1(self):
 
111
        graph = self.make_known_graph(test_graph.ancestry_1)
 
112
        self.assertEqual([NULL_REVISION], graph.get_parent_keys('rev1'))
 
113
        self.assertEqual(['rev1'], graph.get_parent_keys('rev2a'))
 
114
        self.assertEqual(['rev1'], graph.get_parent_keys('rev2b'))
 
115
        self.assertEqual(['rev2a'], graph.get_parent_keys('rev3'))
 
116
        self.assertEqual(['rev2b', 'rev3'],
 
117
                         sorted(graph.get_parent_keys('rev4')))
 
118
        self.assertRaises(KeyError, graph.get_child_keys, 'not_in_graph')
 
119
    
 
120
    def test_parent_with_ghost(self):
 
121
        graph = self.make_known_graph(test_graph.with_ghost)
 
122
        self.assertEqual(None, graph.get_parent_keys('g'))
108
123
 
109
124
    def test_gdfo_ancestry_1(self):
110
125
        graph = self.make_known_graph(test_graph.ancestry_1)