summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-08 20:26:07 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-08 20:26:09 -0800
commit8d97683a28bdaa4cf170a78b5094d467f5f018ef (patch)
treef48e9811a63bc48bbd96530c534ad7fb25283386
parent4e51c1b8fb78b4806e389263a22adb0a4a6b78bc (diff)
downloadfatcat-8d97683a28bdaa4cf170a78b5094d467f5f018ef.tar.gz
fatcat-8d97683a28bdaa4cf170a78b5094d467f5f018ef.zip
partially revert raise_for_status() refactor
Doesn't work with Flask wrapper, of course.
-rw-r--r--python/fatcat_web/search.py1
-rw-r--r--python/tests/routes.py40
-rw-r--r--python/tests/subentity_state.py38
3 files changed, 38 insertions, 41 deletions
diff --git a/python/fatcat_web/search.py b/python/fatcat_web/search.py
index 5cebfde4..471e522a 100644
--- a/python/fatcat_web/search.py
+++ b/python/fatcat_web/search.py
@@ -36,7 +36,6 @@ def do_search(q, limit=50, fulltext_only=True):
(app.config['ELASTICSEARCH_BACKEND'], app.config['ELASTICSEARCH_INDEX']),
json=search_request)
- #rv.raise_for_status()
if resp.status_code != 200:
print("elasticsearch non-200 status code: " + str(resp.status_code))
print(resp.content)
diff --git a/python/tests/routes.py b/python/tests/routes.py
index 7b4ac442..bca7cc0f 100644
--- a/python/tests/routes.py
+++ b/python/tests/routes.py
@@ -9,7 +9,7 @@ from fixtures import *
def test_static_routes(app):
for route in ('/health', '/robots.txt', '/', '/about'):
rv = app.get(route)
- rv.raise_for_status()
+ assert rv.status_code == 200
assert app.get("/static/bogus/route").status_code == 404
@@ -27,16 +27,16 @@ def test_all_views(app):
assert rv.status_code == 404
rv = app.get('/container/aaaaaaaaaaaaaeiraaaaaaaaai')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/container/aaaaaaaaaaaaaeiraaaaaaaaai/history')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/container/aaaaaaaaaaaaaeiraaaaaaaaai/edit')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/container/create')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/container/lookup')
assert rv.status_code == 400
@@ -48,34 +48,34 @@ def test_all_views(app):
assert rv.status_code == 302
rv = app.get('/creator/aaaaaaaaaaaaaircaaaaaaaaai')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/creator/aaaaaaaaaaaaaircaaaaaaaaai/history')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/creator/aaaaaaaaaaaaaircaaaaaaaaai/edit')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/creator/lookup?orcid=0000-0003-2088-7465')
assert rv.status_code == 302
rv = app.get('/file/aaaaaaaaaaaaamztaaaaaaaaai')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/file/lookup?sha1=7d97e98f8af710c7e7fe703abc8f639e0ee507c4')
assert rv.status_code == 302
rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/history')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/edit')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/release/create')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/release/lookup?doi=10.123/abc')
assert rv.status_code == 302
@@ -84,22 +84,22 @@ def test_all_views(app):
assert rv.status_code == 302
rv = app.get('/release/search')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/work/aaaaaaaaaaaaavkvaaaaaaaaai')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/work/aaaaaaaaaaaaavkvaaaaaaaaai/history')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/work/aaaaaaaaaaaaavkvaaaaaaaaai/edit')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/work/create')
assert rv.status_code == 404
rv = app.get('/editgroup/aaaaaaaaaaaabo53aaaaaaaaae')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/editgroup/ccccccccccccccccccccccccca')
print(rv)
@@ -110,7 +110,7 @@ def test_all_views(app):
#assert rv.status_code == 302
rv = app.get('/editor/aaaaaaaaaaaabkvkaaaaaaaaae')
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/editor/aaaaaaaaaaaabkvkaaaaaaaaae/changelog')
- rv.raise_for_status()
+ assert rv.status_code == 200
diff --git a/python/tests/subentity_state.py b/python/tests/subentity_state.py
index 799f5e03..03362686 100644
--- a/python/tests/subentity_state.py
+++ b/python/tests/subentity_state.py
@@ -36,7 +36,7 @@ def test_relation_states(api, app):
eg = quick_eg(api)
j2 = api.get_container(api.create_container(j2, editgroup_id=eg.editgroup_id).ident)
rv = app.get('/container/{}'.format(j2.ident))
- rv.raise_for_status()
+ assert rv.status_code == 200
# create inter-related entities
eg = quick_eg(api)
@@ -57,15 +57,14 @@ def test_relation_states(api, app):
assert r1.contribs[0].creator.display_name == "test person"
assert r1.contribs[0].creator.state == "active"
rv = app.get('/release/{}'.format(r1.ident))
- rv.raise_for_status()
+ assert rv.status_code == 200
# delete creator
eg = quick_eg(api)
api.delete_creator(c1.ident, editgroup_id=eg.editgroup_id)
api.accept_editgroup(eg.editgroup_id)
rv = app.get('/creator/{}'.format(c1.ident))
- # TODO: HTTP status "Gone"?
- rv.raise_for_status()
+ assert rv.status_code == 200 # TODO: HTTP status "Gone"?
c1_deleted = api.get_creator(c1.ident)
assert c1_deleted.state == "deleted"
@@ -78,7 +77,7 @@ def test_relation_states(api, app):
assert r1.contribs[0].creator.display_name is None
assert r1.contribs[0].creator.state == "deleted"
rv = app.get('/release/{}'.format(r1.ident))
- rv.raise_for_status()
+ assert rv.status_code == 200
# wip container
eg = quick_eg(api)
@@ -95,7 +94,7 @@ def test_relation_states(api, app):
assert r1.contribs[0].creator.display_name is None
assert r1.contribs[0].creator.state == "deleted"
rv = app.get('/release/{}'.format(r1.ident))
- rv.raise_for_status()
+ assert rv.status_code == 200
# redirect release
r2 = api.get_release(r2.ident, expand="container,creators,files")
@@ -117,7 +116,7 @@ def test_relation_states(api, app):
rv = app.get('/release/{}'.format(r2.ident))
assert rv.status_code == 302
rv = app.get('/file/{}'.format(f2.ident))
- rv.raise_for_status()
+ assert rv.status_code == 200
# delete release
eg = quick_eg(api)
@@ -129,11 +128,10 @@ def test_relation_states(api, app):
assert r2.files is None
assert r2.contribs is None
rv = app.get('/release/{}'.format(r2.ident))
- # TODO: HTTP Gone?
- rv.raise_for_status()
+ assert rv.status_code == 200 # TODO: HTTP Gone?
rv = app.get('/file/{}'.format(f2.ident))
print(rv.data)
- rv.raise_for_status()
+ assert rv.status_code == 200
def test_app_entity_states(api, app):
@@ -173,23 +171,23 @@ def test_app_entity_states(api, app):
# all entities
rv = app.get('/container/{}'.format(j1.ident))
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/container/{}'.format(j2.ident))
assert rv.status_code == 302
rv = app.get('/creator/{}'.format(c1.ident))
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/creator/{}'.format(c2.ident))
assert rv.status_code == 302
rv = app.get('/file/{}'.format(f1.ident))
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/file/{}'.format(f2.ident))
assert rv.status_code == 302
rv = app.get('/release/{}'.format(r1.ident))
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/release/{}'.format(r2.ident))
assert rv.status_code == 302
rv = app.get('/work/{}'.format(r1.work_id))
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/work/{}'.format(r2.work_id))
assert rv.status_code == 302
@@ -204,23 +202,23 @@ def test_app_entity_states(api, app):
# all entities
rv = app.get('/container/{}'.format(j1.ident))
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/container/{}'.format(j2.ident))
assert rv.status_code == 302
rv = app.get('/creator/{}'.format(c1.ident))
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/creator/{}'.format(c2.ident))
assert rv.status_code == 302
rv = app.get('/file/{}'.format(f1.ident))
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/file/{}'.format(f2.ident))
assert rv.status_code == 302
rv = app.get('/release/{}'.format(r1.ident))
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/release/{}'.format(r2.ident))
assert rv.status_code == 302
rv = app.get('/work/{}'.format(r1.work_id))
- rv.raise_for_status()
+ assert rv.status_code == 200
rv = app.get('/work/{}'.format(r2.work_id))
assert rv.status_code == 302