Feat: write is_finishable
This commit is contained in:
@@ -12,9 +12,14 @@ actions = {"DO": action_done}
|
||||
|
||||
def test_schedule_append():
|
||||
scheduler = Scheduler(actions)
|
||||
tasks = [Task(action="DO", args={}, deps=[], output="end")]
|
||||
tasks = [
|
||||
Task(action="DO", args={}, deps=["dep1", "dep2"], output="end1"),
|
||||
Task(action="DO", args={}, deps=["dep1", "dep3"], output="end2"),
|
||||
]
|
||||
scheduler.append(tasks)
|
||||
assert scheduler.tasks == tasks
|
||||
assert scheduler.all_deps == {"dep1", "dep2", "dep3"}
|
||||
assert scheduler.all_output == {"end1", "end2"}
|
||||
|
||||
|
||||
def test_schedule_dispatch():
|
||||
@@ -48,6 +53,9 @@ def test_schedule_multiple_tasks():
|
||||
t2 = Task(action="DO", args={"task": "two"}, deps=[], output="two")
|
||||
t3 = Task(action="DO", args={"task": "three"}, deps=[], output="three")
|
||||
scheduler.append([t1, t2, t3])
|
||||
|
||||
assert scheduler.is_finishable() == True
|
||||
|
||||
result = scheduler.next()
|
||||
assert result == "[] - {'task': 'one'} - one - done"
|
||||
assert scheduler.tasks == [t2, t3]
|
||||
@@ -71,6 +79,8 @@ def test_schedule_multiple_tasks_with_dependencies():
|
||||
t3 = Task(action="DO", args={"task": "three"}, deps=[], output="three")
|
||||
scheduler.append([t1, t2, t3])
|
||||
|
||||
assert scheduler.is_finishable() == True
|
||||
|
||||
result = scheduler.next()
|
||||
assert result == "[] - {'task': 'three'} - three - done"
|
||||
assert scheduler.tasks == [t1, t2]
|
||||
@@ -99,6 +109,9 @@ def test_schedule_multiple_tasks_with_undoable_dependencies():
|
||||
t1 = Task(action="DO", args={"task": "one"}, deps=["three"], output="one")
|
||||
t2 = Task(action="DO", args={"task": "two"}, deps=[], output="two")
|
||||
scheduler.append([t1, t2])
|
||||
|
||||
assert scheduler.is_finishable() == False
|
||||
|
||||
scheduler.run()
|
||||
assert scheduler.tasks == [t1]
|
||||
assert scheduler.done == ["two"]
|
||||
|
||||
Reference in New Issue
Block a user