Skip to content

Commit

Permalink
Add some test (more test TBD)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManiMozaffar committed Mar 31, 2024
1 parent 34fc027 commit 19c693a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
Empty file added tests/__init__.py
Empty file.
69 changes: 69 additions & 0 deletions tests/test_triggers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from datetime import datetime

import pytz

from aioclock.triggers import At


def test_at_trigger():
# test this sunday
trigger = At(at="every sunday", hour=14, minute=1, second=0, tz="Europe/Istanbul")

val = trigger._get_next_ts(
datetime(
year=2024,
month=3,
day=31,
hour=14,
minute=00,
second=0,
tzinfo=pytz.timezone("Europe/Istanbul"),
)
)
assert val == 60

# test next week
trigger = At(at="every sunday", hour=14, second=59, tz="Europe/Istanbul")

val = trigger._get_next_ts(
datetime(
year=2024,
month=3,
day=31,
hour=14,
minute=0,
second=0,
tzinfo=pytz.timezone("Europe/Istanbul"),
)
)
assert val == 59

# test every day
trigger = At(at="every day", hour=14, second=59, tz="Europe/Istanbul")
val = trigger._get_next_ts(
datetime(
year=2024,
month=3,
day=31,
hour=14,
minute=0,
second=0,
tzinfo=pytz.timezone("Europe/Istanbul"),
)
)
assert val == 59

# test next week
trigger = At(at="every saturday", hour=14, second=0, tz="Europe/Istanbul")
val = trigger._get_next_ts(
datetime(
year=2024,
month=3,
day=31,
hour=14,
minute=0,
second=0,
tzinfo=pytz.timezone("Europe/Istanbul"),
)
)
assert val == 518400

0 comments on commit 19c693a

Please sign in to comment.