コード例 #1
0
def test_graph_ready_after_task_completed():
    # given
    dependencies = {
        'a': {'b', 'c'},
        'b': {'c'},
        'c': set(),
    }

    funcs = {
        'a': a,
        'b': b,
        'c': c,
    }

    graph = taskmap.create_graph(funcs, dependencies)
    ready = taskmap.get_ready_tasks(graph)

    # when
    for func in ready:
        taskmap.mark_as_done(graph, func)

    results = taskmap.get_ready_tasks(graph)

    # then
    assert results == ['b']
コード例 #2
0
def test_tasks_can_be_marked_done():
    # given
    funcs = {'a': a, 'b': b}
    dependencies = {'a': ['b'], 'b': []}

    # when
    graph = taskmap.create_graph(funcs, dependencies, done=['b'])

    # then
    assert taskmap.get_ready_tasks(graph) == ['a']
コード例 #3
0
def test_graph_ordered_ready():
    # given
    dependencies = {'a': set(), 'b': set()}
    funcs = {'a': a, 'b': b}
    io_bound = ['a']
    graph = taskmap.create_graph(funcs, dependencies, io_bound=io_bound)

    # when
    results = taskmap.get_ready_tasks(graph)

    # then
    assert results == ['a', 'b']
コード例 #4
0
def test_graph_ready():
    # given
    dependencies = {
        'a': {'b', 'c'},
        'b': {'c'},
        'c': set(),
    }

    funcs = {
        'a': a,
        'b': b,
        'c': c,
    }

    graph = taskmap.create_graph(funcs, dependencies)

    # when
    results = taskmap.get_ready_tasks(graph)

    # then
    assert results == ['c']
コード例 #5
0
def test_mark_as_done_except():
    # given
    dependencies = {
        'a': {'b', 'c'},
        'b': {'c'},
        'c': set(),
    }

    funcs = {
        'a': a,
        'b': b,
        'c': c,
    }

    graph = taskmap.create_graph(funcs, dependencies)
    graph = taskmap.mark_as_done_except(graph, ['c'])

    results = taskmap.get_ready_tasks(graph)

    # then
    assert results == ['c']