Exemplo n.º 1
0
    def test_multi_root(self):
        self.do_wiring()
        other_root = Node('dual_root')
        other_root.add_downstream(self.top_node._downstream_nodes[0])

        with self.assertRaises(ValueError):
            other_root.top_node
Exemplo n.º 2
0
    def test_flattened_list(self):
        pipeline = Pipeline(TestNode('a') | [[Node('b'), Node('c')]])

        with print_catcher() as catcher:
            print(pipeline)

        self.assertTrue('a | [b, c]' in catcher.txt)
Exemplo n.º 3
0
    def test_ror(self):
        a = Node('a')
        b = Node('b')
        c = Node('c')
        d = Node('d')

        p = Pipeline(a | ([b, c] | d))
        with print_catcher() as catcher:
            print(p)
        self.assertTrue('a | [b, c]' in catcher.txt)
        self.assertTrue('c | d' in catcher.txt)
        self.assertTrue('b | d' in catcher.txt)
Exemplo n.º 4
0
 def test_non_node_connect(self):
     node = Node('a')
     other = 'not a node'
     with self.assertRaises(ValueError):
         node.add_downstream(other)
Exemplo n.º 5
0
    def do_explicit_wiring(self):
        # define nodes
        a = Node('a')
        b = Node('b')
        c = Node('c')
        d = Node('d')
        e = Node('e')
        f = Node('f')
        g = Node('g')
        h = Node('h')
        i = Node('i')
        j = Node('j')
        k = Node('k')
        l = Node('l')
        m = Node('m')
        n = Node('n')

        # save a list of all nodes
        self.node_list = [a, b, c, d, e, f, g, h, i, j, k, l, m, n]
        self.top_node = a

        # wire up the nodes
        a.add_downstream(b)
        a.add_downstream(c)

        c.add_downstream(d)
        c.add_downstream(e)

        e.add_downstream(f)
        e.add_downstream(g)
        e.add_downstream(h)
        e.add_downstream(i)

        f.add_downstream(j)
        g.add_downstream(j)
        h.add_downstream(j)
        i.add_downstream(j)

        d.add_downstream(k)
        j.add_downstream(k)

        b.add_downstream(l)
        k.add_downstream(l)

        l.add_downstream(m)
        l.add_downstream(n)