diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-24 16:16:22 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-24 16:16:30 -0800 |
commit | a85de0b6e82c65d932c84a41b284083b4879934a (patch) | |
tree | 231688205efb16670471c48ca719d3e636771f3d /python/tests | |
parent | 6b1b131ba5e899a069fe280663d331932a8cbae5 (diff) | |
download | fatcat-a85de0b6e82c65d932c84a41b284083b4879934a.tar.gz fatcat-a85de0b6e82c65d932c84a41b284083b4879934a.zip |
tweak crossref import, and update tests
Diffstat (limited to 'python/tests')
-rw-r--r-- | python/tests/files/crossref-works.single.json | 24 | ||||
-rw-r--r-- | python/tests/import_crossref.py | 35 |
2 files changed, 44 insertions, 15 deletions
diff --git a/python/tests/files/crossref-works.single.json b/python/tests/files/crossref-works.single.json index e3d2e05c..f00c2142 100644 --- a/python/tests/files/crossref-works.single.json +++ b/python/tests/files/crossref-works.single.json @@ -36,6 +36,10 @@ }, "delay-in-days": 6452, "content-version": "tdm" + }, + { + "URL": "http://creativecommons.org/licenses/by-nc-nd/3.0/", + "content-version": "vor" } ], "content-domain": { @@ -71,7 +75,11 @@ "source": "Crossref", "is-referenced-by-count": 5, "title": [ - "Renormalized perturbation theory by the moment method for degenerate states: Anharmonic oscillators" + "Renormalized perturbation theory by the moment method for degenerate states: Anharmonic oscillators", + "some other title" + ], + "original-title": [ + "Renormalized perturbation theory auf deutsch" ], "prefix": "10.1002", "volume": "66", @@ -79,7 +87,8 @@ { "given": "Marcelo D.", "family": "Radicioni", - "affiliation": [] + "affiliation": [], + "sequence": "first" }, { "given": "Carlos G.", @@ -90,6 +99,11 @@ "given": "Francisco M.", "family": "Fern�ndez", "affiliation": [] + }, + { + "given": "", + "family": "", + "affiliation": [] } ], "editor": [ @@ -108,6 +122,7 @@ ], "member": "311", "ISBN": ["85-359-0277-5", "978-3-16-148410-0"], + "archive": ["Portico", "LOCKSS"], "reference": [ { "key": "10.1002/(SICI)1097-461X(1998)66:4<261::AID-QUA1>3.0.CO;2-T-BIB1", @@ -115,6 +130,7 @@ "volume": "57", "first-page": "1734", "year": "1972", + "medium": "DVD", "journal-title": "J. Chem. Phys.", "DOI": "10.1063/1.1678462", "doi-asserted-by": "crossref" @@ -131,11 +147,11 @@ }, { "key": "10.1002/(SICI)1097-461X(1998)66:4<261::AID-QUA1>3.0.CO;2-T-BIB3", - "author": "Fernández", + "author": "", "volume": "43", "year": "1987", "unstructured": "and Hypervirial Theorems, Lecture Notes in Chemistry, Vol. 43, (Springer, Berlin, 1987).", - "volume-title": "Hypervirial Theorems, Lecture Notes in Chemistry", + "volume-title": "Hypervirial Theorem’s, Lecture Notes in Chemistry <3", "DOI": "10.1007/978-3-642-93349-3", "doi-asserted-by": "crossref" }, diff --git a/python/tests/import_crossref.py b/python/tests/import_crossref.py index 6e7f72c5..cb2143b3 100644 --- a/python/tests/import_crossref.py +++ b/python/tests/import_crossref.py @@ -70,34 +70,47 @@ def test_crossref_dict_parse(crossref_importer): # not a single line raw = json.loads(f.read()) r = crossref_importer.parse_record(raw) - extra = r.extra['crossref'] + # ensure the API server is ok with format + JsonLinePusher(crossref_importer, [json.dumps(raw)]).run() + + print(r.extra) assert r.title == "Renormalized perturbation theory by the moment method for degenerate states: Anharmonic oscillators" assert r.doi == "10.1002/(sici)1097-461x(1998)66:4<261::aid-qua1>3.0.co;2-t" assert r.publisher == "Wiley-Blackwell" - print(extra) - assert extra['container-title'] == ["International Journal of Quantum Chemistry"] assert r.release_type == "article-journal" assert r.release_status == "published" + assert r.license_slug == "CC-BY-NC-ND" + assert r.original_title == "Renormalized perturbation theory auf deutsch" assert r.isbn13 == "978-3-16-148410-0" - assert 'subtitle' not in extra - assert 'archive' not in extra - assert 'funder' not in extra - assert len(r.contribs) == 5 + assert 'subtitle' not in r.extra + assert 'subtitle' not in r.extra['crossref'] + assert 'funder' not in r.extra + assert 'funder' not in r.extra['crossref'] + # matched by ISSN, so shouldn't be in there + #assert extra['container_name'] == "International Journal of Quantum Chemistry" + assert r.extra['aliases'] == ["some other title"] + assert r.extra['crossref']['archive'] == ['Portico', 'LOCKSS'] + assert len(r.contribs) == 6 assert r.contribs[0].raw_name == "Marcelo D. Radicioni" assert r.contribs[0].index == 0 + assert r.contribs[0].extra['seq'] == "first" assert r.contribs[1].raw_affiliation == "Some University" assert r.contribs[1].extra['more_affiliations'] == ["Some Department"] assert r.contribs[1].role == "author" - assert r.contribs[3].role == "editor" - assert r.contribs[3].index is None - assert r.contribs[4].role == "translator" + assert r.contribs[4].role == "editor" assert r.contribs[4].index is None + assert r.contribs[4].extra is None + assert r.contribs[5].role == "translator" + assert r.contribs[5].index is None assert len(r.refs) == 25 assert r.refs[0].key == "BIB1" assert r.refs[0].year == 1972 assert r.refs[0].locator == "1734" assert r.refs[0].container_name == "J. Chem. Phys." - assert r.refs[0].extra['crossref'] == {"volume": "57", "author": "Swenson", "doi": "10.1063/1.1678462"} + assert r.refs[0].extra == {"volume": "57", "author": "Swenson", "doi": "10.1063/1.1678462", "medium": "DVD"} + assert r.refs[2].key == 'BIB3' + assert r.refs[2].extra.get('author') is None + assert r.refs[2].container_name == "Hypervirial Theorem's, Lecture Notes in Chemistry <3" assert r.refs[3].container_name == "Large Order Perturbation Theory and Summation Methods in Quantum Mechanics, Lecture Notes in Chemistry" def test_stateful_checking(crossref_importer_existing): |