Example #1
0
    def test_error_thrown(self):
        """Nodes without output ports cannot produce output.

        .. note::
            This is very different from python's functions that return None
            by default.
        """
        with self.assertRaises(dl.data_types.DeltaIOError):
            with dl.DeltaGraph():
                no_message = terminate_non_const(5)
                terminate_non_const(no_message)
Example #2
0
    def test_non_split_fails_check(self):
        """If splitter nodes are not added for some reason, for instnance
        if the graph is hacked by Deltahackers, we raise an error.
        """
        with dl.DeltaGraph() as graph:
            output = return_1_non_const()
            terminate_non_const(output)
            terminate_non_const(output)
            terminate_non_const(output)

            # note: we are still in the "with" context
            with self.assertRaises(dl.data_types.DeltaIOError):
                graph.check()
Example #3
0
    def test_const_node(self):
        """Constant node has one output reused multiple times."""
        with dl.DeltaGraph() as graph:
            output = return_1_const()
            terminate_non_const(output)
            terminate_non_const(output)
            terminate_non_const(output)

        self.assertTrue(graph.check())
        self.assertEqual(len(graph.nodes), 5)
        self.assertEqual(type(graph.find_node_by_name("return_1_const").body),
                         dl.wiring.PyConstBody)
        self.assertEqual(type(graph.find_node_by_name("splitter").body),
                         dl.wiring.PyConstBody)
Example #4
0
    def test_non_const_node_via_placeholder(self):
        """Non-constant node created via a placeholder has one output reused
        multiple times."""
        with dl.DeltaGraph() as graph:
            output = dl.placeholder_node_factory()
            terminate_non_const(output)
            terminate_non_const(output)
            terminate_non_const(output)

            output.specify_by_node(return_1_non_const())

        self.assertTrue(graph.check())
        self.assertEqual(len(graph.nodes), 5)
        self.assertEqual(
            type(graph.find_node_by_name("return_1_non_const").body),
            dl.wiring.PyFuncBody)
        self.assertEqual(type(graph.find_node_by_name("splitter").body),
                         dl.wiring.PyFuncBody)