summaryrefslogtreecommitdiffstats
path: root/python/tests
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-04-18 15:27:30 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-04-18 15:27:30 -0700
commit873a167634167838568ad9303ff29673339a4641 (patch)
tree8d8c66a0411737c4eba3218222b5d2295af77068 /python/tests
parent759867197348f93d04e695782e7e337c7a69ea85 (diff)
downloadfatcat-873a167634167838568ad9303ff29673339a4641.tar.gz
fatcat-873a167634167838568ad9303ff29673339a4641.zip
arabesque import tests
Diffstat (limited to 'python/tests')
-rw-r--r--python/tests/files/arabesque_example.json10
-rw-r--r--python/tests/files/arabesque_example.sqlite3bin0 -> 176128 bytes
-rw-r--r--python/tests/import_arabesque.py52
3 files changed, 62 insertions, 0 deletions
diff --git a/python/tests/files/arabesque_example.json b/python/tests/files/arabesque_example.json
new file mode 100644
index 00000000..50d96b15
--- /dev/null
+++ b/python/tests/files/arabesque_example.json
@@ -0,0 +1,10 @@
+{"postproc_status": "200", "final_sha1": "XXLYXZKYAC5RZGS6I4AFXLC6IESHSPD3", "final_status_code": "200", "final_domain": "files.eccomasproceedia.org", "hit": 1, "breadcrumbs": "-", "identifier": "10.123/abc", "final_timestamp": "201810300511", "final_was_dedupe": 0, "initial_domain": "files.eccomasproceedia.org", "final_url": "https://files.eccomasproceedia.org/papers/compdyn-2015/1114.pdf?mtime=20170329172028", "initial_url": "https://files.eccomasproceedia.org/papers/compdyn-2015/1114.pdf?mtime=20170329172028", "final_mimetype": "application/pdf"}
+{"postproc_status": "500", "final_sha1": "X7WDYGM7CTCNP232F5TWK2A62RQDFQX3", "final_status_code": "200", "final_domain": "oru.diva-portal.org", "hit": 1, "breadcrumbs": "-", "identifier": "10.123/abc", "final_timestamp": "201810300511", "final_was_dedupe": 0, "initial_domain": "oru.diva-portal.org", "final_url": "http://oru.diva-portal.org/smash/get/diva2:138559/FULLTEXT01", "initial_url": "http://oru.diva-portal.org/smash/get/diva2:138559/FULLTEXT01", "final_mimetype": "application/pdf"}
+{"postproc_status": null, "final_sha1": "L763R3EZCHPH7XJLNRHBYXL5Q2LAEJC5", "final_status_code": "200", "final_domain": "files.eccomasproceedia.org", "hit": 1, "breadcrumbs": "-", "identifier": "10.7712/120113.4766.c1181", "final_timestamp": "201810300511", "final_was_dedupe": 0, "initial_domain": "files.eccomasproceedia.org", "final_url": "https://files.eccomasproceedia.org/papers/compdyn-2013/C1181.pdf?mtime=20170330153901", "initial_url": "https://files.eccomasproceedia.org/papers/compdyn-2013/C1181.pdf?mtime=20170330153901", "final_mimetype": "application/pdf"}
+{"postproc_status": null, "final_sha1": "KZR7WSB2G4IMKE2Z6ON5SN6E3AI7LYQZ", "final_status_code": "200", "final_domain": "www.termedia.pl", "hit": 1, "breadcrumbs": "-", "identifier": null, "final_timestamp": "201810300511", "final_was_dedupe": 1, "initial_domain": "www.termedia.pl", "final_url": "https://www.termedia.pl/Journal/-41/pdf-15163-7?filename=Trudnosci", "initial_url": "https://www.termedia.pl/Journal/-41/pdf-15163-7?filename=Trudnosci", "final_mimetype": "application/pdf"}
+{"postproc_status": null, "final_sha1": "YAKODW2FUCFLAHJIVIQ55ZJTLWRI5IDY", "final_status_code": "200", "final_domain": "www.scielo.br", "hit": 1, "breadcrumbs": "-", "identifier": "10.1590/s0104-11691993000200003", "final_timestamp": "201810300511", "final_was_dedupe": 1, "initial_domain": "www.scielo.br", "final_url": "http://www.scielo.br/pdf/rlae/v1n2/v1n2a03.pdf", "initial_url": "http://www.scielo.br/pdf/rlae/v1n2/v1n2a03.pdf", "final_mimetype": "application/pdf"}
+{"postproc_status": null, "final_sha1": "W6A5C3W45ZPSKUKINNEOKHF7VIGLNT7V", "final_status_code": "200", "final_domain": "files.eccomasproceedia.org", "hit": 1, "breadcrumbs": "-", "identifier": "10.7712/100016.2436.6566", "final_timestamp": "201810300511", "final_was_dedupe": 0, "initial_domain": "files.eccomasproceedia.org", "final_url": "https://files.eccomasproceedia.org/papers/eccomas-congress-2016/6566.pdf?mtime=20170308164900", "initial_url": "https://files.eccomasproceedia.org/papers/eccomas-congress-2016/6566.pdf?mtime=20170308164900", "final_mimetype": "application/pdf"}
+{"postproc_status": null, "final_sha1": "L5ZJCCH5NIV2EDOTQ54M5VIAYSVQWSNN", "final_status_code": "200", "final_domain": "files.eccomasproceedia.org", "hit": 1, "breadcrumbs": "-", "identifier": "10.7712/120117.5608.18010", "final_timestamp": "201810300511", "final_was_dedupe": 0, "initial_domain": "files.eccomasproceedia.org", "final_url": "https://files.eccomasproceedia.org/papers/compdyn-2017/18010.pdf?mtime=20171002111627", "initial_url": "https://files.eccomasproceedia.org/papers/compdyn-2017/18010.pdf?mtime=20171002111627", "final_mimetype": "application/pdf"}
+{"postproc_status": null, "final_sha1": "DHPTE53TRRLZSAP4SO3A3BL5AAVWIT26", "final_status_code": "200", "final_domain": "files.eccomasproceedia.org", "hit": 1, "breadcrumbs": "-", "identifier": "10.7712/100016.2360.4678", "final_timestamp": "201810300511", "final_was_dedupe": 0, "initial_domain": "files.eccomasproceedia.org", "final_url": "https://files.eccomasproceedia.org/papers/eccomas-congress-2016/4678.pdf?mtime=20170308164728", "initial_url": "https://files.eccomasproceedia.org/papers/eccomas-congress-2016/4678.pdf?mtime=20170308164728", "final_mimetype": "application/pdf"}
+{"postproc_status": null, "final_sha1": "FM5ZQWTUQ2N7T7SXFNLCVA6N5RWQRTI6", "final_status_code": "200", "final_domain": "files.eccomasproceedia.org", "hit": 1, "breadcrumbs": "-", "identifier": "10.7712/100016.2380.8613", "final_timestamp": "201810300511", "final_was_dedupe": 0, "initial_domain": "files.eccomasproceedia.org", "final_url": "https://files.eccomasproceedia.org/papers/eccomas-congress-2016/8613.pdf?mtime=20170308165111", "initial_url": "https://files.eccomasproceedia.org/papers/eccomas-congress-2016/8613.pdf?mtime=20170308165111", "final_mimetype": "application/pdf"}
+{"postproc_status": null, "final_sha1": "Z3KITYKYIOYXXXFRUMVXVU6WS4VPWE3D", "final_status_code": "200", "final_domain": "www.scielo.br", "hit": 1, "breadcrumbs": "-", "identifier": "10.1590/s1413-99362009000200012", "final_timestamp": "201810300511", "final_was_dedupe": 1, "initial_domain": "www.scielo.br", "final_url": "http://www.scielo.br/pdf/pci/v14n2/v14n2a12.pdf", "initial_url": "http://www.scielo.br/pdf/pci/v14n2/v14n2a12.pdf", "final_mimetype": "application/pdf"}
diff --git a/python/tests/files/arabesque_example.sqlite3 b/python/tests/files/arabesque_example.sqlite3
new file mode 100644
index 00000000..7c89bff0
--- /dev/null
+++ b/python/tests/files/arabesque_example.sqlite3
Binary files differ
diff --git a/python/tests/import_arabesque.py b/python/tests/import_arabesque.py
new file mode 100644
index 00000000..516b0ec2
--- /dev/null
+++ b/python/tests/import_arabesque.py
@@ -0,0 +1,52 @@
+
+import json
+import pytest
+from fatcat_tools.importers import ArabesqueMatchImporter, SqlitePusher
+from fixtures import api
+
+
+@pytest.fixture(scope="function")
+def arabesque_importer(api):
+ yield ArabesqueMatchImporter(api, extid_type="doi")
+
+# TODO: use API to check that entities actually created...
+def test_arabesque_importer_basic(arabesque_importer):
+ SqlitePusher(arabesque_importer, 'tests/files/arabesque_example.sqlite3', "crawl_result").run()
+
+def test_arabesque_importer(arabesque_importer):
+ last_index = arabesque_importer.api.get_changelog(limit=1)[0].index
+ arabesque_importer.bezerk_mode = True
+ counts = SqlitePusher(arabesque_importer, 'tests/files/arabesque_example.sqlite3', "crawl_result").run()
+ assert counts['insert'] == 1
+ assert counts['exists'] == 0
+ assert counts['skip'] == 490
+
+ # fetch most recent editgroup
+ change = arabesque_importer.api.get_changelog_entry(index=last_index+1)
+ eg = change.editgroup
+ assert eg.description
+ assert "identifier/url seedlist" in eg.description.lower()
+ assert eg.extra['git_rev']
+ assert "fatcat_tools.ArabesqueMatchImporter" in eg.extra['agent']
+
+ # re-insert; should skip
+ arabesque_importer.reset()
+ arabesque_importer.bezerk_mode = False
+ counts = SqlitePusher(arabesque_importer, 'tests/files/arabesque_example.sqlite3', "crawl_result").run()
+ assert counts['insert'] == 0
+ assert counts['exists'] == 1
+ assert counts['skip'] == 490
+
+def test_arabesque_dict_parse(arabesque_importer):
+ with open('tests/files/arabesque_example.json', 'r') as f:
+ raw = json.loads(f.readline())
+ f = arabesque_importer.parse_record(raw)
+ assert f.sha1 == "bdd78be55800bb1c9a5e47005bac5e4124793c7b"
+ assert f.mimetype == "application/pdf"
+ assert len(f.urls) == 2
+ for u in f.urls:
+ if u.rel == "web":
+ assert u.url.startswith("https://files.eccomasproceedia.org/")
+ if u.rel == "webarchive":
+ assert u.url.startswith("https://web.archive.org/")
+ assert len(f.release_ids) == 1