aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-04-23 19:16:16 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-04-23 19:16:16 -0700
commit88de9b35a388c4a690f46a24dfbfdb261fb520c0 (patch)
treee533cd884b1e8d44335257bd039f68368847927a /tests
parent2f5cd249ff0f7a6621885ec751349575dd0f1c9d (diff)
downloadfatcat-88de9b35a388c4a690f46a24dfbfdb261fb520c0.tar.gz
fatcat-88de9b35a388c4a690f46a24dfbfdb261fb520c0.zip
basic DOI lookup
Diffstat (limited to 'tests')
-rw-r--r--tests/api.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/api.py b/tests/api.py
index 6823aa6d..d9158b87 100644
--- a/tests/api.py
+++ b/tests/api.py
@@ -208,3 +208,29 @@ def test_api_rich_create(app):
# test that editor's active edit group is now invalid
editor = Editor.query.first()
assert editor.active_edit_group == None
+
+def test_api_release_lookup(rich_app):
+ app = rich_app
+
+ rv = app.get('/v0/release/1',
+ headers={"content-type": "application/json"})
+ assert rv.status_code == 200
+ obj = json.loads(rv.data.decode('utf-8'))
+
+ rv = app.get('/v0/release/lookup',
+ data=json.dumps(dict(doi="10.1234/5678")),
+ headers={"content-type": "application/json"})
+ assert rv.status_code == 200
+ obj = json.loads(rv.data.decode('utf-8'))
+ assert obj['doi'] == "10.1234/5678"
+ assert obj.get('id') != None
+
+ rv = app.get('/v0/release/lookup',
+ data=json.dumps(dict(doi="10.1234/5678_noexit")),
+ headers={"content-type": "application/json"})
+ assert rv.status_code == 404
+
+ rv = app.get('/v0/release/lookup',
+ data=json.dumps(dict(doi="not_even_valid_doi")),
+ headers={"content-type": "application/json"})
+ assert rv.status_code == 400