Ejemplo n.º 1
0
 def test__add_function_nodes(self, typed_func):
     ex = DagExecutor()
     ex._add_function_nodes(typed_func)
     for node in ['a', 'b', 'func']:
         assert ex[node]
     assert ('a', 'func') in ex._graph.edges and ('b',
                                                  'func') in ex._graph.edges
Ejemplo n.º 2
0
    def test_break_on_cycle(self):
        def a1(a2):
            return

        def a2(a1):
            return

        ex = DagExecutor()
        with pytest.raises(ValueError):
            ex.add_functions({'a1': a1, 'a2': a2})
Ejemplo n.º 3
0
 def test__add_or_update_node_existing_node(self, mock_nodes):
     ex = DagExecutor()
     ex._add_or_update_node(mock_nodes[0])
     # Add body to node:
     mock_nodes[0].body = sum
     ex._add_or_update_node(mock_nodes[0])
     assert ex['a'] == mock_nodes[0]
Ejemplo n.º 4
0
    def test_with_mock_script(self, mock_script_loc):
        ex = DagExecutor()
        ex.add_function_scripts(mock_script_loc)
        ex.plan()

        assert ex.initial_nodes == {'a', 'b', 'c'}
        # This is actually not a terrific test since the topological sort is not
        # guaranteed to be stable!
        assert [node.name for node in ex.execution_plan
                ] == ['var1', 'var2', 'var3', 'var0']
Ejemplo n.º 5
0
def test_add_function_scripts(mock_script_loc, mock_funcs):
    ex = DagExecutor()
    ex.add_function_scripts(mock_script_loc)
    for fname in mock_funcs:
        assert fname in ex
Ejemplo n.º 6
0
 def test_cant_add_if_already_planned(self, mock_funcs):
     ex = DagExecutor()
     ex.plan()
     with pytest.raises(ValueError):
         ex.add_functions(mock_funcs)
Ejemplo n.º 7
0
 def test_add_funcs(self, mock_funcs):
     ex = DagExecutor()
     ex.add_functions(mock_funcs)
     for fname in mock_funcs:
         assert fname in ex
Ejemplo n.º 8
0
 def test__add_or_update_node_new_node(self, mock_nodes):
     ex = DagExecutor()
     ex._add_or_update_node(mock_nodes[0])
     assert ex['a'] == mock_nodes[0]