~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__known_graph.py

  • Committer: John Arbash Meinel
  • Date: 2009-11-30 17:25:22 UTC
  • mto: This revision was merged to the branch mainline in revision 4849.
  • Revision ID: john@arbash-meinel.com-20091130172522-m373yel3msmjppey
Implement KnownGraph.add_node() for the pyrex version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
161
161
        self.assertGDFO(graph, 'rev4', 5)
162
162
        graph.add_node('rev4', ['rev3', 'rev2b'])
163
163
        self.assertGDFO(graph, 'rev4', 5)
 
164
        # This also works if we use a tuple rather than a list
 
165
        graph.add_node('rev4', ('rev3', 'rev2b'))
 
166
 
 
167
    def test_add_existing_node_mismatched_parents(self):
 
168
        graph = self.make_known_graph(test_graph.ancestry_1)
 
169
        self.assertRaises(ValueError, graph.add_node, 'rev4',
 
170
                          ['rev2b', 'rev3'])
164
171
 
165
172
    def test_add_node_with_ghost_parent(self):
166
173
        graph = self.make_known_graph(test_graph.ancestry_1)
320
327
        self.assertEqual(set(['a', 'c']), graph.heads(['a', 'c', 'e', 'g']))
321
328
        self.assertEqual(set(['a', 'c']), graph.heads(['a', 'c', 'f']))
322
329
 
 
330
    def test_filling_in_ghosts_resets_head_cache(self):
 
331
        if not self.do_cache:
 
332
            raise tests.TestNotApplicable('testing the cache behavior')
 
333
        graph = self.make_known_graph(test_graph.with_ghost)
 
334
        self.assertEqual(set(['e', 'g']), graph.heads(['e', 'g']))
 
335
        # 'g' is filled in, and decends from 'e', so the heads result is now
 
336
        # different
 
337
        graph.add_node('g', ['e'])
 
338
        self.assertEqual(set(['g']), graph.heads(['e', 'g']))
 
339
 
323
340
 
324
341
class TestKnownGraphTopoSort(TestCaseWithKnownGraph):
325
342