my.calendar.holidays: unhardcode calendar, detect it from the location data

This commit is contained in:
Dima Gerasimov 2020-10-09 20:44:47 +01:00 committed by karlicoss
parent bdb5dcd221
commit 96113ad5ae
5 changed files with 49 additions and 7 deletions

View file

@ -1,6 +1,19 @@
from pathlib import Path
import pytest # type: ignore
from my.calendar.holidays import is_holiday
def test() -> None:
assert is_holiday('20190101')
assert not is_holiday('20180601')
assert is_holiday('20200906') # national holiday in Bulgaria
@pytest.fixture(autouse=True)
def prepare(tmp_path: Path):
from . import tz
# todo meh. fixtures can't be called directly?
orig = tz.prepare.__wrapped__ # type: ignore
yield from orig(tmp_path)

View file

@ -29,9 +29,12 @@ def test_future() -> None:
def test_tz() -> None:
# todo hmm, the way it's implemented at the moment, never returns None?
# not present in the test data
tz = LTZ._get_tz(D('20200101 10:00:00'))
assert tz is None
assert tz is not None
assert tz.zone == 'Europe/Sofia'
tz = LTZ._get_tz(D('20170801 11:00:00'))
assert tz is not None
@ -70,7 +73,7 @@ def prepare(tmp_path: Path):
class location:
class home:
current = (1.0, 1.0)
current = (42.697842, 23.325973) # Bulgaria, Sofia
past = [
((40.7128, -74.0060), '2005-12-04'), # NY
]