-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34fc027
commit 19c693a
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |