Пример #1
0
def test_node_inputs():
    env = make_test_env()
    g = Graph(env)
    df = datafunction(function_t1_source)
    node = g.create_node(key="node", function=df)
    df = datafunction(function_t1_sink)
    node1 = g.create_node(key="node1", function=df, input=node)
    pi = node1.get_interface()
    assert len(pi.inputs) == 1
    assert pi.outputs == DEFAULT_OUTPUTS
    assert list(node1.declared_inputs.keys()) == ["input"]
Пример #2
0
def test_python_function():
    p = datafunction(function_t1_sink)
    assert (
        p.name == function_t1_sink.__name__
    )  # TODO: do we really want this implicit name? As long as we error on duplicate should be ok

    k = "name1"
    p = datafunction(function_t1_sink, name=k)
    assert p.name == k
    assert p.key == f"{DEFAULT_LOCAL_NAMESPACE}.{k}"

    pi = p.get_interface()
    assert pi is not None
Пример #3
0
def test_node_no_inputs():
    env = make_test_env()
    g = Graph(env)
    df = datafunction(function_t1_source)
    node1 = g.create_node(key="node1", function=df)
    assert {node1: node1}[node1] is node1  # Test hash
    pi = node1.get_interface()
    assert pi.inputs == {}
    assert pi.outputs != {}
    assert node1.declared_inputs == {}
Пример #4
0
def test_any_schema_interface():
    env = make_test_env()
    env.add_module(core)

    def function_any(input: DataBlock) -> DataFrame:
        pass

    df = datafunction(function_any)
    pi = df.get_interface()
    assert pi.get_single_non_recursive_input().schema_like == "Any"
    assert pi.get_default_output().schema_like == "Any"
Пример #5
0
def test_node_stream_inputs():
    pi = datafunction(function_stream).get_interface()
    assert len(pi.inputs) == 1
    assert pi.get_single_non_recursive_input().input_type == InputType(
        "Stream")
Пример #6
0
def test_function_interface(function_like: DataFunctionLike,
                            expected: DataFunctionInterface):
    p = datafunction(function_like)
    val = p.get_interface()
    assert set(val.inputs) == set(expected.inputs)
    assert val.outputs == expected.outputs