Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemanspiff2007 committed Apr 14, 2021
1 parent d1d1eea commit dd856b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/jobs/test_job_onetime.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import asyncio
import time

import pytest

from eascheduler.const import SKIP_EXECUTION
from eascheduler.errors import OneTimeJobCanNotBeSkipped, JobAlreadyCanceledException
from eascheduler.errors import JobAlreadyCanceledException, OneTimeJobCanNotBeSkipped
from eascheduler.jobs.job_one_time import OneTimeJob
from eascheduler.schedulers import AsyncScheduler
from tests.helper import mocked_executor, set_now
Expand Down Expand Up @@ -43,3 +44,15 @@ async def test_remove():

with pytest.raises(JobAlreadyCanceledException):
j.cancel()


@pytest.mark.asyncio
async def test_init():
s = AsyncScheduler()
j = OneTimeJob(s, lambda x: x)

j._initialize_base_time(None)
assert j._next_base <= round(time.time(), 3)

j._initialize_base_time(3)
assert j._next_base <= round(time.time() + 3, 3)
4 changes: 4 additions & 0 deletions tests/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ async def test_at(view: SchedulerView):

view.at(time(11), lambda x: x)
assert s.jobs[0].get_next_run() == datetime(2001, 1, 2, 11)

view.at(time(13), lambda x: x)
assert s.jobs[0].get_next_run() == datetime(2001, 1, 1, 13)

view.at(5, lambda x: x)
assert s.jobs[0].get_next_run() == datetime(2001, 1, 1, 12, 0, 5)


@pytest.mark.asyncio
async def test_every(view: SchedulerView):
Expand Down

0 comments on commit dd856b3

Please sign in to comment.