def test_raw_func_node_id_is_unique_per_function(): def toto1(): return 1 def toto2(): return 2 n1 = RawFuncNode(toto1) n2 = RawFuncNode(toto2) assert n1.get_id() != n2.get_id() assert n1.get_id() == RawFuncNode(toto1).get_id()
def test_evaluation_fail_if_port_mismatch_outputs(): def func(): return 1, 2 pg = PortGraph() pg.add_vertex(0) pg.add_out_port(0, 'res', 0) n = RawFuncNode(func) n.add_output('res', "descr") pg.set_actor(0, n) algo = BruteEvaluation(pg) env = EvaluationEnvironment() ws = WorkflowState(pg) assert_raises(EvaluationError, lambda: algo.eval(env, ws))
def test_raw_func_node_return_value(): def func(): pass n = RawFuncNode(func) assert n() is None assert_raises(TypeError, lambda: n((1, 2))) def func(): return 1 n = RawFuncNode(func) assert n() == 1 assert n(()) == 1 def func(a, *args): return a + sum(args) n = RawFuncNode(func) assert n((1, 2, 3)) == 6
def test_raw_func_node_reset_is_doing_nothing(): def func(): pass n = RawFuncNode(func) assert n.reset() is None
def test_raw_func_node_func_is_callable(): assert_raises(TypeError, lambda: RawFuncNode(None)) assert_raises(TypeError, lambda: RawFuncNode("toto")) assert_raises(TypeError, lambda: RawFuncNode(1))