Пример #1
0
def test_three_forked():
    dag = {
        'a': Activity(),
        'b': Activity(deps=set('a')),
        'c': Activity(deps=set('a'))
    }
    path, _ = find_path(dag, {'b'})
    assert ['a', 'b'] == path
    path, _ = find_path(dag, {'c'})
    assert ['a', 'c'] == path
    path, _ = find_path(dag, {'b', 'c'})
    assert ['a', 'b', 'c'] == path
Пример #2
0
def test_three_forked_done():
    dag = {
        'a': Activity(),
        'b': Activity(deps=set('a')),
        'c': Activity(deps=set('a'))
    }
    path, already_done = find_path(dag, {'b'}, done={'a'})
    assert ['b'] == path
    assert ['a'] == already_done
    path, already_done = find_path(dag, {'c'}, done={'a'})
    assert ['c'] == path
    assert ['a'] == already_done
    path, already_done = find_path(dag, {'b', 'c'}, done={'a'})
    assert ['b', 'c'] == path
    assert ['a'] == already_done
Пример #3
0
def test_five_forked():
    dag = {
        'a': Activity(),
        'b': Activity(deps=set('a')),
        'c': Activity(deps=set('b')),
        'd': Activity(deps=set('a')),
        'e': Activity(deps=set('c'))
    }
    path, _ = find_path(dag, {'d'})
    assert ['a', 'd'] == path
    path, _ = find_path(dag, {'e'})
    assert ['a', 'b', 'c', 'e'] == path
    path, _ = find_path(dag, {'d', 'e'})
    assert ['a', 'd', 'b', 'c', 'e'] == path
    path, _ = find_path(dag, {'b', 'c', 'd', 'e'})
    assert ['a', 'b', 'c', 'd', 'e'] == path
Пример #4
0
def test_three_linear_done():
    dag = {
        'a': Activity(),
        'b': Activity(deps=set('a')),
        'c': Activity(deps=set('b'))
    }
    # just a is done
    path, already_done = find_path(dag, {'c'}, done={'a'})
    assert ['b', 'c'] == path
    assert ['a'] == already_done
    # b is done, which implies that a is done
    path, already_done = find_path(dag, {'c'}, done={'b'})
    assert ['c'] == path
    assert ['b'] == already_done
    # a and b are done, only b matters
    path, already_done = find_path(dag, {'c'}, done={'a', 'b'})
    assert ['c'] == path
    assert ['b'] == already_done
Пример #5
0
def test_five_forked_done():
    dag = {
        'a': Activity(),
        'b': Activity(deps=set('a')),
        'c': Activity(deps=set('b')),
        'd': Activity(deps=set('a')),
        'e': Activity(deps=set('c'))
    }
    path, already_done = find_path(dag, {'d'}, done={'a'})
    assert ['d'] == path
    assert ['a'] == already_done
    path, already_done = find_path(dag, {'e'}, done={'b'})
    assert ['c', 'e'] == path
    assert ['b'] == already_done
    path, already_done = find_path(dag, {'d', 'e'}, done={'a', 'b'})
    assert ['d', 'c', 'e'] == path
    assert ['a', 'b'] == already_done
    path, already_done = find_path(dag, {'b', 'c', 'd', 'e'}, done={'a', 'c'})
    assert ['b', 'd', 'e'] == path
    assert ['c', 'a'] == already_done
Пример #6
0
def test_two_dep_done():
    dag = {'a': Activity(), 'b': Activity(deps=set('a'))}
    path, already_done = find_path(dag, {'b'}, done={'a'})
    assert ['b'] == path
    assert ['a'] == already_done
Пример #7
0
def test_two_unrelated_done():
    dag = {'a': Activity(), 'b': Activity()}
    path, already_done = find_path(dag, {'a', 'b'}, done={'a'})
    assert ['b'] == path
    assert ['a'] == already_done
Пример #8
0
def test_single_done():
    path, already_done = find_path({'a': Activity()}, {'a'}, done={'a'})
    assert [] == path
    assert ['a'] == already_done
Пример #9
0
def test_empty_done():
    path, already_done = find_path({}, set(), done={'a'})
    assert [] == path
    assert [] == already_done
Пример #10
0
def test_empty():
    path, _ = find_path({}, set())
    assert [] == path
Пример #11
0
def test_two_dep():
    dag = {'a': Activity(), 'b': Activity(deps=set('a'))}
    path, _ = find_path(dag, {'b'})
    assert ['a', 'b'] == path
Пример #12
0
def test_two_unrelated():
    dag = {'a': Activity(), 'b': Activity()}
    path, _ = find_path(dag, {'a', 'b'})
    assert ['a', 'b'] == path
Пример #13
0
def test_single():
    path, _ = find_path({'a': Activity()}, {'a'})
    assert ['a'] == path