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'
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'
def test__DAG_is_cyclic(): A, B = get_two_tasks() dag = DAG() dag.add_dependency(B, depends_on=A) assert not dag.is_cyclic(), 'acyclic graph idenfied as cyclic' with pytest.raises(CyclicGraphError): dag.add_dependency(A, depends_on=B)
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)
def test__DAG_add_dependency(): A, B = get_two_tasks() dag = DAG() dag.add_dependency(B, A) assert dag._edges[A] == set([B])
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,}