~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_graph.py

  • Committer: abentley
  • Date: 2006-04-20 23:47:53 UTC
  • mfrom: (1681 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1683.
  • Revision ID: abentley@lappy-20060420234753-6a6874b76f09f86d
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from bzrlib.tests import TestCase
2
 
from bzrlib.graph import node_distances, nodes_by_distance
 
2
from bzrlib.graph import node_distances, nodes_by_distance, Graph
3
3
 
4
4
class TestBase(TestCase):
 
5
 
5
6
    def edge_add(self, *args):
6
7
        for start, end in zip(args[:-1], args[1:]):
7
8
            if start not in self.graph:
47
48
        distances = node_distances(self.graph, descendants, 'A')
48
49
        self.assertEqual(distances['C'], 3)
49
50
 
 
51
 
 
52
class TestGraph(TestCase):
 
53
 
 
54
    def test_get_descendants(self):
 
55
        # Graph objects let you get a descendants graph in 
 
56
        # node: {direct-children:distance} which contains
 
57
        # known children, including ghost children
 
58
        graph = Graph()
 
59
        graph.add_ghost('ghost')
 
60
        graph.add_node('rev1', ['ghost'])
 
61
        # check the result contains ghosts:
 
62
        self.assertEqual({'ghost': {'rev1': 1}, 'rev1': {}},
 
63
                         graph.get_descendants())