From cd3f2996a3e8c904fd66898da093d13345a06337 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Sun, 26 Apr 2020 12:25:49 +0100 Subject: [PATCH] port tests for takeout from kython --- tests/README.org | 3 +++ tests/takeout.py | 28 +++++++++++++++++++--------- tests/youtube.py | 11 ++++++++++- 3 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 tests/README.org diff --git a/tests/README.org b/tests/README.org new file mode 100644 index 0000000..c1c8015 --- /dev/null +++ b/tests/README.org @@ -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! diff --git a/tests/takeout.py b/tests/takeout.py index 918582f..8272849 100644 --- a/tests/takeout.py +++ b/tests/takeout.py @@ -1,11 +1,14 @@ #!/usr/bin/env python3 +from datetime import datetime from itertools import islice +import pytz from my.core.cachew import disable_cachew disable_cachew() 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): @@ -32,18 +35,25 @@ import pytest # type: ignore ) def test_parser(path: str): 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) - - results = [] - for res in read_html(tpath, path): - results.append(res) - + results = list(read_html(tpath, path)) + # TODO assert len > 100 or something? 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): # without xmllint (splitting by '