示例#1
0
    def test_invalidate_partial(self):
        comparison_pg = ProductGraph(validator=lambda _: True)
        chain_a = list('ABCDEF')
        chain_b = list('GHIJKL')

        # Add two dependency chains to the primary graph.
        self._mk_chain(self.pg, chain_a)
        self._mk_chain(self.pg, chain_b)

        # Add only the dependency chain we won't invalidate to the comparison graph.
        self._mk_chain(comparison_pg, chain_b)

        # Invalidate one of the chains in the primary graph from the right-most node.
        self.pg.invalidate(lambda node: node == chain_a[-1])

        # Ensure the final state of the primary graph matches the comparison graph.
        self.assertEquals(self.pg.completed_nodes(),
                          comparison_pg.completed_nodes())
        self.assertEquals(self.pg.dependents(), comparison_pg.dependents())
        self.assertEquals(self.pg.dependencies(), comparison_pg.dependencies())
        self.assertEquals(self.pg.cyclic_dependencies(),
                          comparison_pg.cyclic_dependencies())
示例#2
0
 def setUp(self):
     self.pg = ProductGraph(
         validator=lambda _: True)  # Allow for string nodes for testing.