port tests for takeout from kython
This commit is contained in:
parent
04605d9c09
commit
cd3f2996a3
3 changed files with 32 additions and 10 deletions
3
tests/README.org
Normal file
3
tests/README.org
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
At the moment, some tests here are specific to my data.
|
||||||
|
|
||||||
|
If you know any good public data sources I could test against instead, please let me know!
|
|
@ -1,11 +1,14 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
from datetime import datetime
|
||||||
from itertools import islice
|
from itertools import islice
|
||||||
|
import pytz
|
||||||
|
|
||||||
from my.core.cachew import disable_cachew
|
from my.core.cachew import disable_cachew
|
||||||
disable_cachew()
|
disable_cachew()
|
||||||
|
|
||||||
import my.location.takeout as LT
|
import my.location.takeout as LT
|
||||||
from my.kython.kompress import kopen
|
from my.google.takeout.html import read_html
|
||||||
|
from my.google.takeout.paths import get_last_takeout
|
||||||
|
|
||||||
|
|
||||||
def ilen(it):
|
def ilen(it):
|
||||||
|
@ -32,18 +35,25 @@ import pytest # type: ignore
|
||||||
)
|
)
|
||||||
def test_parser(path: str):
|
def test_parser(path: str):
|
||||||
path = 'Takeout/' + path
|
path = 'Takeout/' + path
|
||||||
from my.google.takeout.html import read_html
|
|
||||||
from my.google.takeout.paths import get_last_takeout
|
|
||||||
|
|
||||||
tpath = get_last_takeout(path=path)
|
tpath = get_last_takeout(path=path)
|
||||||
|
results = list(read_html(tpath, path))
|
||||||
results = []
|
# TODO assert len > 100 or something?
|
||||||
for res in read_html(tpath, path):
|
|
||||||
results.append(res)
|
|
||||||
|
|
||||||
print(len(results))
|
print(len(results))
|
||||||
|
|
||||||
|
|
||||||
|
def test_myactivity_search():
|
||||||
|
path = 'Takeout/My Activity/Search/MyActivity.html'
|
||||||
|
tpath = get_last_takeout(path=path)
|
||||||
|
results = list(read_html(tpath, path))
|
||||||
|
|
||||||
|
res = (
|
||||||
|
datetime(year=2018, month=12, day=17, hour=8, minute=16, second=18, tzinfo=pytz.utc),
|
||||||
|
'https://en.wikipedia.org/wiki/Emmy_Noether&usg=AFQjCNGrSW-iDnVA2OTcLsG3I80H_a6y_Q',
|
||||||
|
'Emmy Noether - Wikipedia',
|
||||||
|
)
|
||||||
|
assert res in results
|
||||||
|
|
||||||
|
|
||||||
def parse_takeout_xmllint(data: str):
|
def parse_takeout_xmllint(data: str):
|
||||||
# without xmllint (splitting by '<div class="content-cell' -- 0.68 secs)
|
# without xmllint (splitting by '<div class="content-cell' -- 0.68 secs)
|
||||||
# with xmllint -- 2 seconds
|
# with xmllint -- 2 seconds
|
||||||
|
|
|
@ -3,9 +3,18 @@
|
||||||
# these tests would only make sense with some existing data? although some of them would work for everyone..
|
# these tests would only make sense with some existing data? although some of them would work for everyone..
|
||||||
# not sure what's a good way of handling this..
|
# not sure what's a good way of handling this..
|
||||||
|
|
||||||
from my.media.youtube import get_watched
|
from my.media.youtube import get_watched, Watched
|
||||||
|
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
watched = get_watched()
|
watched = get_watched()
|
||||||
assert len(watched) > 1000
|
assert len(watched) > 1000
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
import pytz
|
||||||
|
w = Watched(
|
||||||
|
url='https://www.youtube.com/watch?v=hTGJfRPLe08',
|
||||||
|
title='Jamie xx - Gosh',
|
||||||
|
when=datetime(year=2018, month=6, day=21, hour=5, minute=48, second=34, tzinfo=pytz.utc),
|
||||||
|
)
|
||||||
|
assert w in watched
|
||||||
|
|
Loading…
Add table
Reference in a new issue