summaryrefslogtreecommitdiffstats
path: root/python/tests
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-05-21 17:20:17 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-05-21 17:20:17 -0700
commit818a891a5e306e84e8165dec28cc4a5961180e8c (patch)
treebe119d5f35f9f3281de22138e6a69d0d1fac1646 /python/tests
parent90560ba18ac042a23db6995cc07a5cef024bc179 (diff)
downloadfatcat-818a891a5e306e84e8165dec28cc4a5961180e8c.tar.gz
fatcat-818a891a5e306e84e8165dec28cc4a5961180e8c.zip
more JALC importer polish
Diffstat (limited to 'python/tests')
-rw-r--r--python/tests/import_jalc.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/python/tests/import_jalc.py b/python/tests/import_jalc.py
index e92c26c0..693e77f4 100644
--- a/python/tests/import_jalc.py
+++ b/python/tests/import_jalc.py
@@ -1,7 +1,7 @@
import json, gzip
import pytest
-from fatcat_tools.importers import JalcImporter, Bs4XmlFilePusher
+from fatcat_tools.importers import JalcImporter, Bs4XmlFilePusher, Bs4XmlLinesPusher
from fixtures import api
from bs4 import BeautifulSoup
@@ -43,6 +43,33 @@ def test_jalc_importer(jalc_importer):
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:
+ 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
+
+ # fetch most recent editgroup
+ 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']
+
+ last_index = jalc_importer.api.get_changelog(limit=1)[0].index
+ 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 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:
soup = BeautifulSoup(f, "xml")
@@ -51,7 +78,7 @@ def test_jalc_xml_parse(jalc_importer):
print(r.extra)
assert r.title == "New carbides in the Ni-Ti-Mo-C system"
assert r.subtitle == None
- assert r.original_title == "Ni-Ti-Mo-C系に出現する新炭化物相について"
+ assert r.original_title == "Ni-Ti-Mo-C系に出現する新炭化物相について"
assert r.publisher == "Japan Society of Powder and Powder Metallurgy"
assert r.release_type == "article-journal"
assert r.release_stage == "published"