aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-04-23 19:26:56 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-04-23 19:26:56 -0700
commit1f43e85569bd8b23445f9cd6361ea64387d84fa5 (patch)
treed4bc9c7a6890915b9a505b662b531794a0f80623 /tests
parent88de9b35a388c4a690f46a24dfbfdb261fb520c0 (diff)
downloadfatcat-1f43e85569bd8b23445f9cd6361ea64387d84fa5.tar.gz
fatcat-1f43e85569bd8b23445f9cd6361ea64387d84fa5.zip
quick and dirty ISSN+ORCID lookups
Diffstat (limited to 'tests')
-rw-r--r--tests/api.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/api.py b/tests/api.py
index d9158b87..8b495c61 100644
--- a/tests/api.py
+++ b/tests/api.py
@@ -234,3 +234,56 @@ def test_api_release_lookup(rich_app):
data=json.dumps(dict(doi="not_even_valid_doi")),
headers={"content-type": "application/json"})
assert rv.status_code == 400
+
+def test_api_creator_lookup(rich_app):
+ app = rich_app
+
+ rv = app.get('/v0/creator/1',
+ headers={"content-type": "application/json"})
+ assert rv.status_code == 200
+ obj = json.loads(rv.data.decode('utf-8'))
+
+ rv = app.get('/v0/creator/lookup',
+ data=json.dumps(dict(orcid="0000-0002-1825-0097")),
+ headers={"content-type": "application/json"})
+ assert rv.status_code == 200
+ obj = json.loads(rv.data.decode('utf-8'))
+ assert obj['orcid'] == "0000-0002-1825-0097"
+ assert obj.get('id') != None
+
+ rv = app.get('/v0/creator/lookup',
+ data=json.dumps(dict(orcid="0000-0002-1825-0098")),
+ headers={"content-type": "application/json"})
+ assert rv.status_code == 404
+
+ rv = app.get('/v0/creator/lookup',
+ data=json.dumps(dict(orcid="not_even_valid_orcid")),
+ headers={"content-type": "application/json"})
+ assert rv.status_code == 400
+
+
+def test_api_container_lookup(rich_app):
+ app = rich_app
+
+ rv = app.get('/v0/container/1',
+ headers={"content-type": "application/json"})
+ assert rv.status_code == 200
+ obj = json.loads(rv.data.decode('utf-8'))
+
+ rv = app.get('/v0/container/lookup',
+ data=json.dumps(dict(issn="2222-3333")),
+ headers={"content-type": "application/json"})
+ assert rv.status_code == 200
+ obj = json.loads(rv.data.decode('utf-8'))
+ assert obj['issn'] == "2222-3333"
+ assert obj.get('id') != None
+
+ rv = app.get('/v0/container/lookup',
+ data=json.dumps(dict(issn="2222-3334")),
+ headers={"content-type": "application/json"})
+ assert rv.status_code == 404
+
+ rv = app.get('/v0/container/lookup',
+ data=json.dumps(dict(issn="not_even_valid_issn")),
+ headers={"content-type": "application/json"})
+ assert rv.status_code == 400