diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-11-12 21:18:27 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-11-15 16:46:26 -0800 |
commit | 169477c39dc772c0eb1d45f8097215e73f0f6044 (patch) | |
tree | 509ba7973923a0e1c89f953a3ae4ace6f684c00e /python | |
parent | 9d2bde08e9f43942b76ca6d0f6c8845c33c02515 (diff) | |
download | fatcat-169477c39dc772c0eb1d45f8097215e73f0f6044.tar.gz fatcat-169477c39dc772c0eb1d45f8097215e73f0f6044.zip |
test for ingest transform
Diffstat (limited to 'python')
-rw-r--r-- | python/tests/transform_ingest.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/python/tests/transform_ingest.py b/python/tests/transform_ingest.py new file mode 100644 index 00000000..2d5652b8 --- /dev/null +++ b/python/tests/transform_ingest.py @@ -0,0 +1,57 @@ + +import json +import pytest +from fatcat_tools.transforms import release_ingest_request +from fatcat_openapi_client import * +from fixtures import api + +from import_crossref import crossref_importer + +def test_basic_ingest_release(crossref_importer): + with open('tests/files/crossref-works.single.json', 'r') as f: + # not a single line + raw = json.loads(f.read()) + r = crossref_importer.parse_record(raw) + r.state = 'active' + req = release_ingest_request(r) + assert req is not None + +def test_rich_ingest_release(): + r = ReleaseEntity( + title="something", + ident="iznnn644szdwva7khyxqzc5555", + release_year=1234, + license_slug="CC-BY-NC", + ext_ids=ReleaseExtIds(doi="10.123/456"), + refs=[ + ReleaseRef(), + ReleaseRef(target_release_id="iznnn644szdwva7khyxqzc73bi"), + ], + ) + r.state = 'active' + r.container = ContainerEntity( + name="dummy journal", + extra={ + "ia": { + "sim": { + "year_spans": [[1000, 1100]], + }, + }, + "kbart": { + "lockss": { + "year_spans": [[1200, 1300]], + }, + "jstor": { + "year_spans": [[1950, 1960], [1980, 2005]], + }, + }, + "sherpa_romeo": {"color": "blue"}, + "doaj": {"as_of": "2010-02-03"}, + }, + ) + ir = release_ingest_request(r) + assert ir is not None + assert ir['base_url'] == 'https://doi.org/10.123/456' + assert ir['ext_ids']['doi'] == '10.123/456' + assert ir['ext_ids'].get('pmcid') is None + |