diff --git a/pyproject.toml b/pyproject.toml index af458f8..10e3235 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "sched2" -version = "0.8.0" +version = "0.8.1" description = "Event scheduler 2" authors = ["Pedro Rodrigues "] license = "MIT" diff --git a/sched2.py b/sched2.py index fc85bc1..b112447 100644 --- a/sched2.py +++ b/sched2.py @@ -125,6 +125,8 @@ def cron_runner(action): delay = 60 - self.timefunc() % 60 self.enter(delay, 0, cron_runner, (action,)) + return action + return cron_runner @property diff --git a/test_sched2.py b/test_sched2.py index 66c4119..b852e1f 100644 --- a/test_sched2.py +++ b/test_sched2.py @@ -21,6 +21,26 @@ def action(mocker): return mocker.Mock(return_value=False) +def test_repeat_method_returns_action(scheduler, action): + repeat_return_value = scheduler.repeat(1, 1, action, immediate=False) + assert repeat_return_value is action + + +def test_every_decorator_method_returns_action(scheduler, action): + every_return_value = scheduler.every(1)(action) + assert every_return_value is action + + +def test_cron_decorator_method_returns_action(scheduler, action): + cron_return_value = scheduler.cron("* * * * *")(action) + assert cron_return_value is action + + +def test_on_decorator_method_returns_action(scheduler, action): + on_return_value = scheduler.on("event")(action) + assert on_return_value is action + + def test_repeat_adds_a_single_event(scheduler, action): # starts empty assert len(scheduler.queue) == 0