Example #1
0
def test__DAG_get_upstream():
    A, B = get_two_tasks()
    dag = DAG()
    dag.add_dependency(B, depends_on=A)
    assert dag.get_upstream() is not None
    assert dag.get_upstream()[B] == {A}
    assert dag.get_upstream() == {B: {A}}, "Task A is not upstream"
Example #2
0
def test__DAG_get_downstream():
    A, B = get_two_tasks()
    dag = DAG()
    dag.add_dependency(B, depends_on=A)
    assert dag.get_downstream() is not None
    assert dag.get_downstream()[A] == {B}
    assert dag.get_downstream() == {A: {B}}, "Task B is not downstream"
Example #3
0
def test__DAG_get_sinks():
    A, B = get_two_tasks()
    dag = DAG()
    dag.add_dependency(B, depends_on=A)
    assert dag.get_sinks() is not None
    assert dag.get_sinks() == {B}
Example #4
0
def test__DAG_add_dependency_detect_cycle():
    A, B = get_two_tasks()
    dag = DAG()
    dag.add_dependency(B, A)
    with pytest.raises(CyclicGraphError):
        dag.add_dependency(A, B)
Example #5
0
def test__DAG_add_dependency():
    A, B = get_two_tasks()
    dag = DAG()
    dag.add_dependency(B, A)
    assert dag._edges[A] == set([B])