summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-06-28 12:29:10 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-06-28 12:29:14 -0700
commit8589fe48a7446c394441a9f2f48384cd3e457f17 (patch)
tree5d0422c15b83e6c40f54ae60a7610b958580eb8d
parent830a136a5580de2635e3e6c23ce4da27f5ad498c (diff)
downloadfatcat-8589fe48a7446c394441a9f2f48384cd3e457f17.tar.gz
fatcat-8589fe48a7446c394441a9f2f48384cd3e457f17.zip
complete generic entity rev views
Was getting 500s in production from crawlers. Also expand test coverage.
-rw-r--r--python/fatcat_web/routes.py42
-rw-r--r--python/tests/web_entity_views.py54
2 files changed, 60 insertions, 36 deletions
diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py
index 02808577..393df33e 100644
--- a/python/fatcat_web/routes.py
+++ b/python/fatcat_web/routes.py
@@ -261,13 +261,11 @@ def creator_view_metadata(ident):
@app.route('/creator/rev/<revision_id>', methods=['GET'])
def creator_revision_view(revision_id):
- entity = generic_get_entity_revision('creator', revision_id)
- return render_template('creator_view.html', entity_type='creator', entity=entity, editgroup=None)
+ return generic_entity_revision_view('creator', revision_id, 'creator_view.html')
@app.route('/creator/rev/<revision_id>/metadata', methods=['GET'])
def creator_revision_view_metadata(revision_id):
- entity = generic_get_entity_revision('creator', revision_id)
- return render_template('entity_view_metadata.html', entity_type='creator', entity=entity, editgroup=None)
+ return generic_entity_revision_view('creator', revision_id, 'entity_view_metadata.html')
@app.route('/editgroup/<editgroup_id>/creator/<ident>', methods=['GET'])
def creator_editgroup_view(editgroup_id, ident):
@@ -288,13 +286,11 @@ def file_view_metadata(ident):
@app.route('/file/rev/<revision_id>', methods=['GET'])
def file_revision_view(revision_id):
- entity = generic_get_entity_revision('file', revision_id)
- return render_template('file_view.html', entity_type='file', entity=entity, editgroup=None)
+ return generic_entity_revision_view('file', revision_id, 'file_view.html')
@app.route('/file/rev/<revision_id>/metadata', methods=['GET'])
def file_revision_view_metadata(revision_id):
- entity = generic_get_entity_revision('file', revision_id)
- return render_template('entity_view_metadata.html', entity_type='file', entity=entity, editgroup=None)
+ return generic_entity_revision_view('file', revision_id, 'entity_view_metadata.html')
@app.route('/editgroup/<editgroup_id>/file/<ident>', methods=['GET'])
def file_editgroup_view(editgroup_id, ident):
@@ -315,13 +311,11 @@ def fileset_view_metadata(ident):
@app.route('/fileset/rev/<revision_id>', methods=['GET'])
def fileset_revision_view(revision_id):
- entity = generic_get_entity_revision('fileset', revision_id)
- return render_template('fileset_view.html', entity_type='fileset', entity=entity, editgroup=None)
+ return generic_entity_revision_view('fileset', revision_id, 'fileset_view.html')
@app.route('/fileset/rev/<revision_id>/metadata', methods=['GET'])
def fileset_revision_view_metadata(revision_id):
- entity = generic_get_entity_revision('fileset', revision_id)
- return render_template('entity_view_metadata.html', entity_type='fileset', entity=entity, editgroup=None)
+ return generic_entity_revision_view('fileset', revision_id, 'entity_view_metadata.html')
@app.route('/editgroup/<editgroup_id>/fileset/<ident>', methods=['GET'])
def fileset_editgroup_view(editgroup_id, ident):
@@ -342,13 +336,11 @@ def webcapture_view_metadata(ident):
@app.route('/webcapture/rev/<revision_id>', methods=['GET'])
def webcapture_revision_view(revision_id):
- entity = generic_get_entity_revision('webcapture', revision_id)
- return render_template('webcapture_view.html', entity_type='webcapture', entity=entity, editgroup=None)
+ return generic_entity_revision_view('webcapture', revision_id, 'webcapture_view.html')
@app.route('/webcapture/rev/<revision_id>/metadata', methods=['GET'])
def webcapture_revision_view_metadata(revision_id):
- entity = generic_get_entity_revision('webcapture', revision_id)
- return render_template('entity_view_metadata.html', entity_type='webcapture', entity=entity, editgroup=None)
+ return generic_entity_revision_view('webcapture', revision_id, 'entity_view_metadata.html')
@app.route('/editgroup/<editgroup_id>/webcapture/<ident>', methods=['GET'])
def webcapture_editgroup_view(editgroup_id, ident):
@@ -377,23 +369,19 @@ def release_view_metadata(ident):
@app.route('/release/rev/<revision_id>', methods=['GET'])
def release_revision_view(revision_id):
- entity = generic_get_entity_revision('release', revision_id)
- return render_template('release_view.html', entity_type='release', entity=entity, editgroup=None)
+ return generic_entity_revision_view('release', revision_id, 'release_view.html')
@app.route('/release/rev/<revision_id>/contribs', methods=['GET'])
def release_revision_view_contribs(revision_id):
- entity = generic_get_entity_revision('release', revision_id)
- return render_template('release_view_contribs.html', entity_type='release', entity=entity, editgroup=None)
+ return generic_entity_revision_view('release', revision_id, 'release_view_contribs.html')
@app.route('/release/rev/<revision_id>/references', methods=['GET'])
def release_revision_view_references(revision_id):
- entity = generic_get_entity_revision('release', revision_id)
- return render_template('release_view_references.html', entity_type='release', entity=entity, editgroup=None)
+ return generic_entity_revision_view('release', revision_id, 'release_view_references.html')
@app.route('/release/rev/<revision_id>/metadata', methods=['GET'])
def release_revision_view_metadata(revision_id):
- entity = generic_get_entity_revision('release', revision_id)
- return render_template('entity_view_metadata.html', entity_type='release', entity=entity, editgroup=None)
+ return generic_entity_revision_view('release', revision_id, 'entity_view_metadata.html')
@app.route('/editgroup/<editgroup_id>/release/<ident>', methods=['GET'])
def release_editgroup_view(editgroup_id, ident):
@@ -422,13 +410,11 @@ def work_view_metadata(ident):
@app.route('/work/rev/<revision_id>', methods=['GET'])
def work_revision_view(revision_id):
- entity = generic_get_entity_revision('work', revision_id)
- return render_template('work_view.html', entity_type='release', entity=entity, editgroup=None)
+ return generic_entity_revision_view('work', revision_id, 'work_view.html')
@app.route('/work/rev/<revision_id>/metadata', methods=['GET'])
def work_revision_view_metadata(revision_id):
- entity = generic_get_entity_revision('work', revision_id)
- return render_template('entity_view_metadata.html', entity_type='work', entity=entity, editgroup=None)
+ return generic_entity_revision_view('work', revision_id, 'entity_view_metadata.html')
@app.route('/editgroup/<editgroup_id>/work/<ident>', methods=['GET'])
def work_editgroup_view(editgroup_id, ident):
diff --git a/python/tests/web_entity_views.py b/python/tests/web_entity_views.py
index 4e486e78..6bbd6848 100644
--- a/python/tests/web_entity_views.py
+++ b/python/tests/web_entity_views.py
@@ -7,13 +7,14 @@ from fixtures import *
from fatcat_web.forms import ReleaseEntityForm, FileEntityForm, ContainerEntityForm
DUMMY_DEMO_ENTITIES = {
- 'container': 'aaaaaaaaaaaaaeiraaaaaaaaai',
- 'creator': 'aaaaaaaaaaaaaircaaaaaaaaai',
- 'file': 'aaaaaaaaaaaaamztaaaaaaaaai',
- 'fileset': 'aaaaaaaaaaaaaztgaaaaaaaaai',
- 'webcapture': 'aaaaaaaaaaaaa53xaaaaaaaaai',
- 'release': 'aaaaaaaaaaaaarceaaaaaaaaai',
- 'work': 'aaaaaaaaaaaaavkvaaaaaaaaai',
+ 'container': ('aaaaaaaaaaaaaeiraaaaaaaaai', '00000000-0000-0000-1111-fff000000002'),
+ # note inconsistency here (q not i)
+ 'creator': ('aaaaaaaaaaaaaircaaaaaaaaaq', '00000000-0000-0000-2222-fff000000002'),
+ 'file': ('aaaaaaaaaaaaamztaaaaaaaaai', '00000000-0000-0000-3333-fff000000002'),
+ 'fileset': ('aaaaaaaaaaaaaztgaaaaaaaaai', '00000000-0000-0000-6666-fff000000002'),
+ 'webcapture': ('aaaaaaaaaaaaa53xaaaaaaaaai', '00000000-0000-0000-7777-fff000000002'),
+ 'release': ('aaaaaaaaaaaaarceaaaaaaaaai', '00000000-0000-0000-4444-fff000000002'),
+ 'work': ('aaaaaaaaaaaaavkvaaaaaaaaai', '00000000-0000-0000-5555-fff000000002'),
}
REALISTIC_DEMO_ENTITIES = {
@@ -29,12 +30,23 @@ REALISTIC_DEMO_ENTITIES = {
def test_entity_basics(app):
- for entity_type, ident in DUMMY_DEMO_ENTITIES.items():
+ for entity_type, (ident, revision) in DUMMY_DEMO_ENTITIES.items():
# good requests
rv = app.get('/{}/{}'.format(entity_type, ident))
assert rv.status_code == 200
rv = app.get('/{}/{}/history'.format(entity_type, ident))
assert rv.status_code == 200
+ rv = app.get('/{}/{}/metadata'.format(entity_type, ident))
+ assert rv.status_code == 200
+ rv = app.get('/{}/rev/{}'.format(entity_type, revision))
+ assert rv.status_code == 200
+ rv = app.get('/{}/rev/{}/metadata'.format(entity_type, revision))
+ assert rv.status_code == 200
+ print('/editgroup/aaaaaaaaaaaabo53aaaaaaaaaq/{}/{}'.format(entity_type, ident))
+ rv = app.get('/editgroup/aaaaaaaaaaaabo53aaaaaaaaaq/{}/{}'.format(entity_type, ident))
+ assert rv.status_code == 200
+ rv = app.get('/editgroup/aaaaaaaaaaaabo53aaaaaaaaaq/{}/{}/metadata'.format(entity_type, ident))
+ assert rv.status_code == 200
# bad requests
rv = app.get('/{}/9999999999'.format(entity_type))
@@ -98,14 +110,20 @@ def test_web_container(app):
rv = app.get('/container/aaaaaaaaaaaaaeiraaaaaaaaai')
assert rv.status_code == 200
+ rv = app.get('/container/aaaaaaaaaaaaaeiraaaaaaaaai/metadata')
+ assert rv.status_code == 200
rv = app.get('/container/aaaaaaaaaaaaaeiraaaaaaaaai/edit')
assert rv.status_code == 302
rv = app.get('/container/create')
assert rv.status_code == 302
rv = app.get('/container/rev/00000000-0000-0000-1111-fff000000002')
assert rv.status_code == 200
+ rv = app.get('/container/rev/00000000-0000-0000-1111-fff000000002/metadata')
+ assert rv.status_code == 200
rv = app.get('/editgroup/aaaaaaaaaaaabo53aaaaaaaaaq/container/aaaaaaaaaaaaaeiraaaaaaaaai')
assert rv.status_code == 200
+ rv = app.get('/editgroup/aaaaaaaaaaaabo53aaaaaaaaaq/container/aaaaaaaaaaaaaeiraaaaaaaaai/metadata')
+ assert rv.status_code == 200
rv = app.get('/editgroup/aaaaaaaaaaaabo53aaaaaaaaaq/container/aaaaaaaaaaaaaeiraaaaaaaaai/edit')
assert rv.status_code == 302
@@ -228,6 +246,26 @@ def test_web_release(app):
rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai')
assert rv.status_code == 200
+ rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/contribs')
+ assert rv.status_code == 200
+ rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/references')
+ assert rv.status_code == 200
+ rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/metadata')
+ assert rv.status_code == 200
+ rv = app.get('/release/rev/00000000-0000-0000-4444-fff000000002/contribs')
+ assert rv.status_code == 200
+ rv = app.get('/release/rev/00000000-0000-0000-4444-fff000000002/references')
+ assert rv.status_code == 200
+ rv = app.get('/release/rev/00000000-0000-0000-4444-fff000000002/metadata')
+ assert rv.status_code == 200
+ rv = app.get('/editgroup/aaaaaaaaaaaabo53aaaaaaaaaq/release/aaaaaaaaaaaaarceaaaaaaaaai')
+ assert rv.status_code == 200
+ rv = app.get('/editgroup/aaaaaaaaaaaabo53aaaaaaaaaq/release/aaaaaaaaaaaaarceaaaaaaaaai/contribs')
+ assert rv.status_code == 200
+ rv = app.get('/editgroup/aaaaaaaaaaaabo53aaaaaaaaaq/release/aaaaaaaaaaaaarceaaaaaaaaai/references')
+ assert rv.status_code == 200
+ rv = app.get('/editgroup/aaaaaaaaaaaabo53aaaaaaaaaq/release/aaaaaaaaaaaaarceaaaaaaaaai/metadata')
+ assert rv.status_code == 200
rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/edit')
assert rv.status_code == 302