Esempio n. 1
0
    def test_operation_links_multiple(self, graph, sum_op, square_op,
                                      negative_op):
        def my_func(x: int, y: int) -> (int, int):
            return y, x

        my_op = operation(my_func, output_names=("y", "x"))()
        graph.add_operations(sum_op, square_op, negative_op, my_op)
        link1 = (my_op, sum_op, "y", "n1")
        link2 = (my_op, sum_op, "x", "n2")
        link3 = (sum_op, square_op, "sum", "n")
        link4 = (square_op, negative_op, "square", "num")
        graph.add_link(*link1)
        graph.add_link(*link2)
        graph.add_link(*link3)
        graph.add_link(*link4)
        assert graph.operation_links(my_op) == [link1, link2]
        assert graph.operation_links(sum_op) == [link3]
        assert graph.operation_links(negative_op) == []
Esempio n. 2
0
 def test_set_disabled_remove_false(self, graph, sum_op, square_op,
                                    negative_op):
     graph.add_operations(sum_op, square_op, negative_op)
     link1 = (sum_op, square_op, "sum", "n")
     link2 = (square_op, negative_op, "square", "num")
     graph.add_link(*link1)
     graph.add_link(*link2)
     return_value = graph.set_disabled(sum_op, remove_orphan_links=False)
     assert graph.disabled(sum_op) is True
     assert graph.links() == [link1, link2]
     assert return_value == graph.operation_links(sum_op)
 def test_operation_links(self, graph, sum_op, square_op):
     graph.add_operations(sum_op, square_op)
     link = (sum_op, square_op, "sum", "n")
     graph.add_link(*link)
     assert graph.operation_links(sum_op) == [link]
     assert graph.operation_links(square_op) == []
 def test_operation_links_not_in_graph(self, graph, sum_op):
     with pytest.raises(ValueError):
         graph.operation_links(sum_op)
 def test_operation_links_bad_arg(self, graph):
     with pytest.raises(TypeError):
         graph.operation_links("this is not an operation")