Ejemplo n.º 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 structure of the primary graph matches the comparison graph.
        pg_structure = {n: e.structure() for n, e in self.pg._nodes.items()}
        comparison_structure = {
            n: e.structure()
            for n, e in comparison_pg._nodes.items()
        }
        self.assertEquals(pg_structure, comparison_structure)
Ejemplo n.º 2
0
 def setUp(self):
     self.pg = ProductGraph(
         validator=lambda _: True)  # Allow for string nodes for testing.