Ejemplo n.º 1
0
def test__DAG_add_dependency_detect_cycle2():
    A, B = get_two_tasks()
    C = Task("C.py", env="test-env")

    dag = DAG()
    with pytest.raises(CyclicGraphError):
        dag.add_dependencies({A: C, B: A, C: B})
Ejemplo n.º 2
0
def test__Composer_get_schedules():
    A = Task("A.py", "test-exe")
    B = Task("B.py", "test-exe")
    C = Task("C.py", "test-exe")
    Z = Task("Z.py", "test-exe")
    dag = DAG()
    dag.add_tasks({A, B, C, Z})
    dag.add_dependencies({B: A, C: B})
    dq = Composer(dag)

    priorities = dq.get_schedules()
    testable = {}

    # build a testable result dict
    for k, v in priorities.items():
        new_set = set()
        if isinstance(v, Task):
            testable[k] = set(v)
            continue

        for vi in v:
            new_set.add(hash(vi))
        testable[k] = new_set

    assert testable == {1: {hash(A), hash(Z)}, 2: {hash(B)}, 3: {hash(C)}}
Ejemplo n.º 3
0
def test__DAG_add_dependencies():
    A, B = get_two_tasks()
    C = Task("C.py", env="test-env")
    dag = DAG()
    dag.add_dependencies({B: A})
    assert dag._edges[A] == set([B])

    dag = DAG()
    dag.add_dependencies({C: {A, B}})
    assert dag._edges[A] == set([C])
    assert dag._edges[B] == set([C])
Ejemplo n.º 4
0
def test__Composer_get_task_schedules():
    A = Task("A.py", "test-exe")
    B = Task("B.py", "test-exe")
    C = Task("C.py", "test-exe")
    Z = Task("Z.py", "test-exe")
    dag = DAG()
    dag.add_tasks({A, B, C, Z})
    dag.add_dependencies({B: A, C: B})
    dq = Composer(dag)

    priorities = dq.get_task_schedules()

    testable = {hash(k): v for k, v in priorities.items()}
    assert testable == {hash(A): 1, hash(B): 2, hash(C): 3, hash(Z): 1}