From cdfd6b85b386b7bbf9d5a5179ef26970b6e5a4e7 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 2 Nov 2021 18:13:14 -0700 Subject: fmt (black): tests/ --- python/tests/import_shadow.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'python/tests/import_shadow.py') diff --git a/python/tests/import_shadow.py b/python/tests/import_shadow.py index 1caaf780..66661084 100644 --- a/python/tests/import_shadow.py +++ b/python/tests/import_shadow.py @@ -1,4 +1,3 @@ - import json import pytest @@ -11,39 +10,42 @@ from fatcat_tools.importers import JsonLinePusher, ShadowLibraryImporter def shadow_importer(api): yield ShadowLibraryImporter(api) + # TODO: use API to check that entities actually created... def test_shadow_importer_basic(shadow_importer): - with open('tests/files/example_shadow.json', 'r') as f: + with open("tests/files/example_shadow.json", "r") as f: JsonLinePusher(shadow_importer, f).run() + def test_shadow_importer(shadow_importer): last_index = shadow_importer.api.get_changelog(limit=1)[0].index - with open('tests/files/example_shadow.json', 'r') as f: + with open("tests/files/example_shadow.json", "r") as f: shadow_importer.bezerk_mode = True counts = JsonLinePusher(shadow_importer, f).run() - assert counts['insert'] == 2 - assert counts['exists'] == 0 - assert counts['skip'] == 8 + assert counts["insert"] == 2 + assert counts["exists"] == 0 + assert counts["skip"] == 8 # fetch most recent editgroup - change = shadow_importer.api.get_changelog_entry(index=last_index+1) + change = shadow_importer.api.get_changelog_entry(index=last_index + 1) eg = change.editgroup assert eg.description assert "shadow library" in eg.description.lower() - assert eg.extra['git_rev'] - assert "fatcat_tools.ShadowLibraryImporter" in eg.extra['agent'] + assert eg.extra["git_rev"] + assert "fatcat_tools.ShadowLibraryImporter" in eg.extra["agent"] # re-insert; should skip - with open('tests/files/example_shadow.json', 'r') as f: + with open("tests/files/example_shadow.json", "r") as f: shadow_importer.reset() shadow_importer.bezerk_mode = False counts = JsonLinePusher(shadow_importer, f).run() - assert counts['insert'] == 0 - assert counts['exists'] == 2 - assert counts['skip'] == 8 + assert counts["insert"] == 0 + assert counts["exists"] == 2 + assert counts["skip"] == 8 + def test_shadow_dict_parse(shadow_importer): - with open('tests/files/example_shadow.json', 'r') as f: + with open("tests/files/example_shadow.json", "r") as f: raw = json.loads(f.readline()) f = shadow_importer.parse_record(raw) @@ -55,7 +57,9 @@ def test_shadow_dict_parse(shadow_importer): assert len(f.urls) == 2 for u in f.urls: if u.rel == "publisher": - assert u.url.startswith("https://link.springer.com/content/pdf/10.1007%2Fs11626-008-9119-8.pdf") + assert u.url.startswith( + "https://link.springer.com/content/pdf/10.1007%2Fs11626-008-9119-8.pdf" + ) if u.rel == "webarchive": assert u.url.startswith("https://web.archive.org/") assert "20180729135948" in u.url -- cgit v1.2.3