check for equality
This commit is contained in:
parent
9466606d68
commit
6fdbfa2609
1 changed files with 12 additions and 5 deletions
17
sql.py
17
sql.py
|
@ -59,13 +59,20 @@ def iter_db_locs(db_path: Path):
|
||||||
def test(tmp_path):
|
def test(tmp_path):
|
||||||
tdir = Path(tmp_path)
|
tdir = Path(tmp_path)
|
||||||
tdb = tdir / 'test.sqlite'
|
tdb = tdir / 'test.sqlite'
|
||||||
|
|
||||||
test_src = Path('/L/tmp/loc/LocationHistory.json')
|
|
||||||
test_limit = 100
|
test_limit = 100
|
||||||
cache_locs(source=test_src, db_path=tdb, limit=test_limit)
|
test_src = Path('/L/tmp/loc/LocationHistory.json')
|
||||||
|
|
||||||
locs = list(iter_db_locs(tdb))
|
# TODO meh, double loading, but for now fine
|
||||||
assert len(locs) == test_limit
|
with test_src.open('r') as fo:
|
||||||
|
real_locs = list(islice(_load_locations(fo), 0, test_limit))
|
||||||
|
|
||||||
|
cache_locs(source=test_src, db_path=tdb, limit=test_limit)
|
||||||
|
cached_locs = list(iter_db_locs(tdb))
|
||||||
|
assert len(cached_locs) == test_limit
|
||||||
|
def FIXME_tz(locs):
|
||||||
|
# TODO FIXME tzinfo...
|
||||||
|
return [x._replace(dt=x.dt.replace(tzinfo=None)) for x in locs]
|
||||||
|
assert FIXME_tz(real_locs) == FIXME_tz(cached_locs)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
from kython import setup_logzero
|
from kython import setup_logzero
|
||||||
|
|
Loading…
Add table
Reference in a new issue