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']
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']
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']
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']
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']