summaryrefslogtreecommitdiffstats
path: root/python/tests/import_jalc.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2021-11-02 18:13:14 -0700
committerBryan Newbold <bnewbold@robocracy.org>2021-11-02 18:13:14 -0700
commitcdfd6b85b386b7bbf9d5a5179ef26970b6e5a4e7 (patch)
tree5e4034027b51f3ee4d2a488bb2cbb7a75c3bd0d8 /python/tests/import_jalc.py
parent78f08280edea4ff65ca613ad30005c45cc48dea6 (diff)
downloadfatcat-cdfd6b85b386b7bbf9d5a5179ef26970b6e5a4e7.tar.gz
fatcat-cdfd6b85b386b7bbf9d5a5179ef26970b6e5a4e7.zip
fmt (black): tests/
Diffstat (limited to 'python/tests/import_jalc.py')
-rw-r--r--python/tests/import_jalc.py77
1 files changed, 42 insertions, 35 deletions
diff --git a/python/tests/import_jalc.py b/python/tests/import_jalc.py
index c11e2307..4ebc87b4 100644
--- a/python/tests/import_jalc.py
+++ b/python/tests/import_jalc.py
@@ -1,4 +1,3 @@
-
import pytest
from bs4 import BeautifulSoup
from fixtures import *
@@ -8,70 +7,78 @@ from fatcat_tools.importers import Bs4XmlFilePusher, Bs4XmlLinesPusher, JalcImpo
@pytest.fixture(scope="function")
def jalc_importer(api):
- with open('tests/files/ISSN-to-ISSN-L.snip.txt', 'r') as issn_file:
- yield JalcImporter(api, issn_file, extid_map_file='tests/files/example_map.sqlite3', bezerk_mode=True)
+ with open("tests/files/ISSN-to-ISSN-L.snip.txt", "r") as issn_file:
+ yield JalcImporter(
+ api, issn_file, extid_map_file="tests/files/example_map.sqlite3", bezerk_mode=True
+ )
+
@pytest.fixture(scope="function")
def jalc_importer_existing(api):
- with open('tests/files/ISSN-to-ISSN-L.snip.txt', 'r') as issn_file:
- yield JalcImporter(api, issn_file, extid_map_file='tests/files/example_map.sqlite3', bezerk_mode=False)
+ with open("tests/files/ISSN-to-ISSN-L.snip.txt", "r") as issn_file:
+ yield JalcImporter(
+ api, issn_file, extid_map_file="tests/files/example_map.sqlite3", bezerk_mode=False
+ )
+
def test_jalc_importer(jalc_importer):
last_index = jalc_importer.api.get_changelog(limit=1)[0].index
- with open('tests/files/jalc_lod_sample.xml', 'r') as f:
+ with open("tests/files/jalc_lod_sample.xml", "r") as f:
jalc_importer.bezerk_mode = True
counts = Bs4XmlFilePusher(jalc_importer, f, "Description").run()
- assert counts['insert'] == 2
- assert counts['exists'] == 0
- assert counts['skip'] == 0
+ assert counts["insert"] == 2
+ assert counts["exists"] == 0
+ assert counts["skip"] == 0
# fetch most recent editgroup
- change = jalc_importer.api.get_changelog_entry(index=last_index+1)
+ change = jalc_importer.api.get_changelog_entry(index=last_index + 1)
eg = change.editgroup
assert eg.description
assert "jalc" in eg.description.lower()
- assert eg.extra['git_rev']
- assert "fatcat_tools.JalcImporter" in eg.extra['agent']
+ assert eg.extra["git_rev"]
+ assert "fatcat_tools.JalcImporter" in eg.extra["agent"]
last_index = jalc_importer.api.get_changelog(limit=1)[0].index
- with open('tests/files/jalc_lod_sample.xml', 'r') as f:
+ with open("tests/files/jalc_lod_sample.xml", "r") as f:
jalc_importer.bezerk_mode = False
jalc_importer.reset()
counts = Bs4XmlFilePusher(jalc_importer, f, "Description").run()
- assert counts['insert'] == 0
- assert counts['exists'] == 2
- assert counts['skip'] == 0
+ assert counts["insert"] == 0
+ assert counts["exists"] == 2
+ assert counts["skip"] == 0
assert last_index == jalc_importer.api.get_changelog(limit=1)[0].index
+
def test_jalc_importer_lines(jalc_importer):
last_index = jalc_importer.api.get_changelog(limit=1)[0].index
- with open('tests/files/jalc_rdf_sample_100.xml', 'r') as f:
+ with open("tests/files/jalc_rdf_sample_100.xml", "r") as f:
jalc_importer.bezerk_mode = True
counts = Bs4XmlLinesPusher(jalc_importer, f, "<rdf:Description").run()
- assert counts['insert'] == 93
- assert counts['exists'] == 0
- assert counts['skip'] == 0
+ assert counts["insert"] == 93
+ assert counts["exists"] == 0
+ assert counts["skip"] == 0
# fetch most recent editgroup
- change = jalc_importer.api.get_changelog_entry(index=last_index+1)
+ change = jalc_importer.api.get_changelog_entry(index=last_index + 1)
eg = change.editgroup
assert eg.description
assert "jalc" in eg.description.lower()
- assert eg.extra['git_rev']
- assert "fatcat_tools.JalcImporter" in eg.extra['agent']
+ assert eg.extra["git_rev"]
+ assert "fatcat_tools.JalcImporter" in eg.extra["agent"]
last_index = jalc_importer.api.get_changelog(limit=1)[0].index
- with open('tests/files/jalc_rdf_sample_100.xml', 'r') as f:
+ with open("tests/files/jalc_rdf_sample_100.xml", "r") as f:
jalc_importer.bezerk_mode = False
jalc_importer.reset()
counts = Bs4XmlLinesPusher(jalc_importer, f, "<rdf:Description").run()
- assert counts['insert'] == 0
- assert counts['exists'] == 93
- assert counts['skip'] == 0
+ assert counts["insert"] == 0
+ assert counts["exists"] == 93
+ assert counts["skip"] == 0
assert last_index == jalc_importer.api.get_changelog(limit=1)[0].index
+
def test_jalc_xml_parse(jalc_importer):
- with open('tests/files/jalc_lod_sample.xml', 'r') as f:
+ with open("tests/files/jalc_lod_sample.xml", "r") as f:
soup = BeautifulSoup(f, "xml")
r = jalc_importer.parse_record(soup.find_all("Description")[0])
@@ -90,21 +97,21 @@ def test_jalc_xml_parse(jalc_importer):
assert r.pages == "898-902"
assert r.release_year == 1989
# matched by ISSN, so shouldn't be in there?
- #assert extra['container_name'] == "International Journal of Quantum Chemistry"
+ # assert extra['container_name'] == "International Journal of Quantum Chemistry"
assert len(r.contribs) == 4
assert r.contribs[0].raw_name == "Yasuhiko Hashimoto"
assert r.contribs[0].given_name == "Yasuhiko"
assert r.contribs[0].surname == "Hashimoto"
- assert r.contribs[0].extra['original_name']['raw_name'] == "橋本 雍彦"
- assert r.contribs[0].extra['original_name']['given_name'] == "雍彦"
- assert r.contribs[0].extra['original_name']['surname'] == "橋本"
+ assert r.contribs[0].extra["original_name"]["raw_name"] == "橋本 雍彦"
+ assert r.contribs[0].extra["original_name"]["given_name"] == "雍彦"
+ assert r.contribs[0].extra["original_name"]["surname"] == "橋本"
assert r.contribs[3].raw_name == "Teruo Takahashi"
assert r.contribs[3].given_name == "Teruo"
assert r.contribs[3].surname == "Takahashi"
- assert r.contribs[3].extra['original_name']['raw_name'] == "高橋 輝男"
- assert r.contribs[3].extra['original_name']['given_name'] == "輝男"
- assert r.contribs[3].extra['original_name']['surname'] == "高橋"
+ assert r.contribs[3].extra["original_name"]["raw_name"] == "高橋 輝男"
+ assert r.contribs[3].extra["original_name"]["given_name"] == "輝男"
+ assert r.contribs[3].extra["original_name"]["surname"] == "高橋"
assert not r.refs