emfit: propagate errors properly, expose dataframe

This commit is contained in:
Dima Gerasimov 2020-08-20 23:25:14 +01:00 committed by karlicoss
parent 78489157a1
commit d9bbf7cbf0
3 changed files with 97 additions and 39 deletions

View file

@ -1,23 +1,24 @@
from my.emfit import get_datas
from my.emfit import datas
def test():
datas = get_datas()
for d in datas:
def test() -> None:
ds = [x for x in datas() if not isinstance(x, Exception)]
for d in ds:
assert d.start.tzinfo is not None
assert d.end.tzinfo is not None
assert d.sleep_start.tzinfo is not None
assert d.sleep_end.tzinfo is not None
def test_tz():
datas = get_datas()
def test_tz() -> None:
# TODO check errors too?
ds = [x for x in datas() if not isinstance(x, Exception)]
# this was winter time, so GMT, UTC+0
[s0109] = [s for s in datas if s.date.strftime('%Y%m%d') == '20190109']
[s0109] = [s for s in ds if s.date.strftime('%Y%m%d') == '20190109']
assert s0109.end.strftime('%H:%M') == '06:42'
# TODO FIXME ugh, it's broken?...
# summer time, so UTC+1
[s0411] = [s for s in datas if s.date.strftime('%Y%m%d') == '20190411']
[s0411] = [s for s in ds if s.date.strftime('%Y%m%d') == '20190411']
assert s0411.end.strftime('%H:%M') == '09:30'