示例#1
0
def test_glob_nodes(dag):
    aa = dag.layer(name="aa")
    bb = dag.layer(name="bb")
    ac = dag.layer(name="ac")
    dd = dag.layer(name="dd")

    assert dag.glob("a*") == dags.Nodes(aa, ac)
示例#2
0
def test_select_nodes(dag):
    a = dag.layer(name="a")
    bb = dag.layer(name="bb")
    ccc = dag.layer(name="ccc")
    dd = dag.layer(name="dd")

    assert dag.select(lambda n: len(n.name) == 2) == dags.Nodes(bb, dd)
示例#3
0
def test_ancestors_of_nodes_joins_ancestors(dag):
    a = dag.layer(name="a")
    b = a.child_layer(name="b")
    c = dag.layer(name="c")
    d = c.child_layer(name="d")

    assert set(dags.Nodes(b, d).walk_ancestors()) == {a, c}
示例#4
0
def test_descendants_of_nodes_joins_descendants(dag):
    a = dag.layer(name="a")
    b = a.child_layer(name="b")
    c = dag.layer(name="c")
    d = c.child_layer(name="d")

    assert set(dags.Nodes(a, c).walk_descendants()) == {b, d}
示例#5
0
def test_ancestors_doesnt_include_disconnected_piece(dag):
    a = dag.layer(name="a")
    b1 = a.child_layer(name="b1")
    b2 = dag.layer(name="b2")
    c = dags.Nodes(b1, b2).child_layer(name="c")

    d = dag.layer(name="d")

    assert d not in set(c.walk_ancestors())
示例#6
0
def test_ancestors_has_all_ancestors_branching_breadth_first(dag):
    a = dag.layer(name="a")
    b1 = a.child_layer(name="b1")
    b2 = dag.layer(name="b2")
    c = dags.Nodes(b1, b2).child_layer(name="c")

    assert list(c.walk_ancestors(dags.WalkOrder.BREADTH_FIRST)) in (
        [b1, b2, a],
        [b2, b1, a],
    )
示例#7
0
def test_leaves(dag):
    root = dag.layer(name="root")
    middle = root.child_layer(name="middle")
    leaf = middle.child_layer(name="leaf")

    assert dag.leaves == dags.Nodes(leaf)