diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2021-10-12 20:05:30 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2021-10-13 16:21:31 -0700 |
commit | 85f4124d0c70b9fb55e6f549cfd906fcf8783c6f (patch) | |
tree | a60100fbb7db2590014aea7d3f9c186f46a39fcb /python/tests | |
parent | 88497e378e2e4c93906c7485865724133511d4e6 (diff) | |
download | fatcat-85f4124d0c70b9fb55e6f549cfd906fcf8783c6f.tar.gz fatcat-85f4124d0c70b9fb55e6f549cfd906fcf8783c6f.zip |
python: test coverage of rust schema changes
Diffstat (limited to 'python/tests')
-rw-r--r-- | python/tests/api_containers.py | 30 | ||||
-rw-r--r-- | python/tests/api_editor.py | 23 | ||||
-rw-r--r-- | python/tests/api_filesets.py | 4 | ||||
-rw-r--r-- | python/tests/api_releases.py | 4 |
4 files changed, 59 insertions, 2 deletions
diff --git a/python/tests/api_containers.py b/python/tests/api_containers.py index 70dbcd7e..25a10837 100644 --- a/python/tests/api_containers.py +++ b/python/tests/api_containers.py @@ -1,4 +1,5 @@ +import pytest from fatcat_openapi_client import * from fixtures import * @@ -12,6 +13,8 @@ def test_container(api): container_type="journal", publisher="some container publisher", issnl="1234-567X", + issne="1230-0000", + issnp="1234-0001", wikidata_qid="Q954248", extra=dict(a=1, b=2), edit_extra=dict(test_key="containers rule"), @@ -46,11 +49,38 @@ def test_container(api): c2 = api.get_container(c2.ident) assert c2.state == "deleted" +def test_container_bad_idents(api): + + # all the fields! + c1 = ContainerEntity( + name="some container name", + container_type="journal", + publisher="some container publisher", + wikidata_qid="Q954248", + extra=dict(a=1, b=2), + edit_extra=dict(test_key="containers rule"), + ) + + with pytest.raises(ValueError): + c1.issnl = "1234-123 " + + with pytest.raises(ValueError): + c1.issne = "asdf-hhhh" + def test_container_examples(api): c1 = api.get_container('aaaaaaaaaaaaaeiraaaaaaaaam') assert c1.name == "PLOS Medicine" assert c1.issnl == "1549-1277" + assert c1.issne == "1549-1676" + assert c1.issnp == "1549-1277" + assert c1.publication_status == "active" c2 = api.lookup_container(issnl=c1.issnl) assert c1.ident == c2.ident + + c3 = api.lookup_container(issnp=c1.issnp) + assert c1.ident == c3.ident + + c4 = api.lookup_container(issn=c1.issnp) + assert c1.ident == c4.ident diff --git a/python/tests/api_editor.py b/python/tests/api_editor.py index 91881743..ab118501 100644 --- a/python/tests/api_editor.py +++ b/python/tests/api_editor.py @@ -1,4 +1,8 @@ +import pytest + +import fatcat_openapi_client + from fixtures import api @@ -15,3 +19,22 @@ def test_editor_update(api): api.update_editor(editor_id, orig) check = api.get_editor(editor_id) assert check == orig + +def test_editor_get(api): + + editor_id = api.editor_id + api.get_editor(editor_id) + +def test_editor_lookup(api): + + editor_id = api.editor_id + e1 = api.get_editor(editor_id) + + e2 = api.lookup_editor(username=e1.username) + assert e1.editor_id == e2.editor_id + + with pytest.raises(fatcat_openapi_client.rest.ApiException): + api.lookup_editor(username="") + + with pytest.raises(fatcat_openapi_client.rest.ApiException): + api.lookup_editor(username="bogus-username-notfound") diff --git a/python/tests/api_filesets.py b/python/tests/api_filesets.py index 6d755744..be023325 100644 --- a/python/tests/api_filesets.py +++ b/python/tests/api_filesets.py @@ -27,6 +27,7 @@ def test_fileset(api): md5="5f83592b5249671719bbed6ce91ecfa8", sha1="455face3598611458efe1f072e58624790a67266", sha256="429bcafa4d3d0072d5b2511e12c85c1aac1d304011d1c406da14707f7b9cd905", + mimetype="text/plain", extra={"x": 1, "y": "q"}, ), ], @@ -77,7 +78,8 @@ def test_fileset_examples(api): assert fs3.urls[0].url == 'http://other-personal-blog.name/dataset/' assert fs3.urls[1].rel == 'archive' assert fs3.manifest[1].md5 == 'f4de91152c7ab9fdc2a128f962faebff' - assert fs3.manifest[1].extra['mimetype'] == 'application/gzip' + assert fs3.manifest[1].mimetype == 'application/gzip' + assert fs3.manifest[1].extra != None assert fs3.releases[0].ident assert fs3.releases[0].abstracts is None assert fs3.releases[0].refs is None diff --git a/python/tests/api_releases.py b/python/tests/api_releases.py index 9c70f655..389d9831 100644 --- a/python/tests/api_releases.py +++ b/python/tests/api_releases.py @@ -29,10 +29,11 @@ def test_release(api): wikidata_qid="Q1234", isbn13="978-3-16-148410-0", core="187348", - arxiv="aslkdjfh", + arxiv="math.CA/0611800v2", jstor="8328424", mag="9439328", ark="ark:/12025/654xz321", + hdl="20.123.45/asdf", ), volume="84", number="RFC1234", @@ -144,6 +145,7 @@ def test_release_examples(api): api.lookup_release(jstor='1819117828') api.lookup_release(ark='ark:/13030/m53r5pzm') api.lookup_release(mag='992489213') + api.lookup_release(hdl='20.500.23456/ABC/DUMMY') # failed lookup exception type try: |