shared config for tests,add fallback location test
This commit is contained in:
parent
ec1ea9710e
commit
c707116d31
7 changed files with 206 additions and 58 deletions
39
tests/tz.py
39
tests/tz.py
|
@ -1,5 +1,5 @@
|
|||
import sys
|
||||
from datetime import datetime, timedelta, date, timezone
|
||||
from datetime import datetime, timedelta
|
||||
from pathlib import Path
|
||||
|
||||
import pytest # type: ignore
|
||||
|
@ -81,40 +81,15 @@ def D(dstr: str) -> datetime:
|
|||
return datetime.strptime(dstr, '%Y%m%d %H:%M:%S')
|
||||
|
||||
|
||||
# TODO copy pasted from location.py, need to extract some common provider
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def prepare(tmp_path: Path):
|
||||
from .common import reset_modules
|
||||
reset_modules()
|
||||
|
||||
LTZ.config.fast = True
|
||||
|
||||
from .location import _prepare_google_config
|
||||
google = _prepare_google_config(tmp_path)
|
||||
|
||||
class location:
|
||||
home = (
|
||||
# supports ISO strings
|
||||
('2005-12-04' , (42.697842, 23.325973)), # Bulgaria, Sofia
|
||||
# supports date/datetime objects
|
||||
(date(year=1980, month=2, day=15) , (40.7128 , -74.0060 )), # NY
|
||||
# check tz handling..
|
||||
(datetime.fromtimestamp(1600000000, tz=timezone.utc), (55.7558 , 37.6173 )), # Moscow, Russia
|
||||
)
|
||||
# note: order doesn't matter, will be sorted in the data provider
|
||||
class via_ip:
|
||||
pass
|
||||
class gpslogger:
|
||||
pass
|
||||
|
||||
class time:
|
||||
class tz:
|
||||
class via_location:
|
||||
pass # just rely on the defaults...
|
||||
from .shared_config import temp_config
|
||||
conf = temp_config(tmp_path)
|
||||
|
||||
import my.core.cfg as C
|
||||
with C.tmp_config() as config:
|
||||
config.google = google
|
||||
config.time = time
|
||||
config.location = location
|
||||
config.google = conf.google
|
||||
config.time = conf.time
|
||||
config.location = conf.location
|
||||
yield
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue