Feat: append, dispatch and __next__ (basic) scheduler
This commit is contained in:
27
test/test_scheduler.py
Normal file
27
test/test_scheduler.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from bopytex.planner import Task
|
||||
from bopytex.scheduler import Scheduler
|
||||
|
||||
|
||||
def test_schedule_append():
|
||||
actions = {"DO": lambda _: "done"}
|
||||
scheduler = Scheduler(actions)
|
||||
tasks = [Task(action="DO", args={}, deps=[], output="")]
|
||||
scheduler.append(tasks)
|
||||
assert scheduler.tasks == tasks
|
||||
|
||||
def test_schedule_dispatch():
|
||||
actions = {"DO": lambda _: "done"}
|
||||
scheduler = Scheduler(actions)
|
||||
task = Task(action="DO", args={}, deps=[], output="Nothing")
|
||||
result = scheduler.dispatch(task)
|
||||
assert result == "done"
|
||||
|
||||
|
||||
def test_schedule_one_task():
|
||||
actions = {"DO": lambda _: "done"}
|
||||
scheduler = Scheduler(actions)
|
||||
scheduler.append([Task(action="DO", args={}, deps=[], output="Nothing")])
|
||||
result = scheduler.__next__()
|
||||
assert result == "done"
|
||||
assert scheduler.tasks == []
|
||||
assert scheduler.done == ["Nothing"]
|
||||
Reference in New Issue
Block a user