Example #1
0
    def test_add_location_dependencies_also_adds_reverse_dependencies(self):
        graph = {}
        parent_loc = (1, 2)
        child1_loc = (2, 3)
        child2_loc = (3, 4)
        grandchild_loc = (4, 5)

        _add_location_dependencies(graph, parent_loc,
                                   set([child1_loc, child2_loc]))
        expected = {
            parent_loc: Node(parent_loc,
                             children=set([child1_loc, child2_loc])),
            child1_loc: Node(child1_loc, parents=set([parent_loc])),
            child2_loc: Node(child2_loc, parents=set([parent_loc])),
        }
        self.assertEquals(expected, graph)

        _add_location_dependencies(graph, grandchild_loc, set())
        expected = {
            parent_loc: Node(parent_loc,
                             children=set([child1_loc, child2_loc])),
            child1_loc: Node(child1_loc, parents=set([parent_loc])),
            child2_loc: Node(child2_loc, parents=set([parent_loc])),
            grandchild_loc: Node(grandchild_loc),
        }
        self.assertEquals(expected, graph)

        _add_location_dependencies(graph, child1_loc, set([grandchild_loc]))
        expected = {
            parent_loc:
            Node(parent_loc, children=set([child1_loc, child2_loc])),
            child1_loc:
            Node(child1_loc,
                 children=set([grandchild_loc]),
                 parents=set([parent_loc])),
            child2_loc:
            Node(child2_loc, parents=set([parent_loc])),
            grandchild_loc:
            Node(grandchild_loc, parents=set([child1_loc])),
        }
        self.assertEquals(expected, graph)
    def test_add_location_dependencies_also_adds_reverse_dependencies(self):
        graph = {}
        parent_loc = (1, 2)
        child1_loc = (2, 3)
        child2_loc = (3, 4)
        grandchild_loc = (4, 5)

        _add_location_dependencies(graph, parent_loc, set([child1_loc, child2_loc]))
        expected = {
            parent_loc: Node(parent_loc, children=set([child1_loc, child2_loc])),
            child1_loc: Node(child1_loc, parents=set([parent_loc])),
            child2_loc: Node(child2_loc, parents=set([parent_loc])),
        }
        self.assertEquals(expected, graph)

        _add_location_dependencies(graph, grandchild_loc, set())
        expected = {
            parent_loc: Node(parent_loc, children=set([child1_loc, child2_loc])),
            child1_loc: Node(child1_loc, parents=set([parent_loc])),
            child2_loc: Node(child2_loc, parents=set([parent_loc])),
            grandchild_loc: Node(grandchild_loc),
        }
        self.assertEquals(expected, graph)

        _add_location_dependencies(graph, child1_loc, set([grandchild_loc]))
        expected = {
            parent_loc: Node(parent_loc, children=set([child1_loc, child2_loc])),
            child1_loc: Node(
                child1_loc,
                children=set([grandchild_loc]),
                parents=set([parent_loc])
            ),
            child2_loc: Node(child2_loc, parents=set([parent_loc])),
            grandchild_loc: Node(grandchild_loc, parents=set([child1_loc])),
        }
        self.assertEquals(expected, graph)
 def test_add_location_dependencies_does(self):
     graph = {}
     dependencies = set([sentinel.dependencies])
     _add_location_dependencies(graph, sentinel.location, dependencies)
     self.assertEquals(type(graph[sentinel.location]), Node)
     self.assertEquals(graph[sentinel.location].children, dependencies)
Example #4
0
 def test_add_location_dependencies_does(self):
     graph = {}
     dependencies = set([sentinel.dependencies])
     _add_location_dependencies(graph, sentinel.location, dependencies)
     self.assertEquals(type(graph[sentinel.location]), Node)
     self.assertEquals(graph[sentinel.location].children, dependencies)