From 88de9b35a388c4a690f46a24dfbfdb261fb520c0 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 23 Apr 2018 19:16:16 -0700 Subject: basic DOI lookup --- tests/api.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') 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 -- cgit v1.2.3