diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-05-07 19:18:24 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-05-07 19:18:24 -0700 |
commit | 8688a97077385f4ab7651a76d916c71efb6ecfe8 (patch) | |
tree | ae0e63d9641b3a40f6590364e91f5e5a618b93d8 /python | |
parent | 38dc6686c3acf1d3e970e5969da1e893915cf87e (diff) | |
download | fatcat-8688a97077385f4ab7651a76d916c71efb6ecfe8.tar.gz fatcat-8688a97077385f4ab7651a76d916c71efb6ecfe8.zip |
basic coverage of web entity creation, merge
Diffstat (limited to 'python')
-rw-r--r-- | python/tests/web_editing.py | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/python/tests/web_editing.py b/python/tests/web_editing.py new file mode 100644 index 00000000..473c81bc --- /dev/null +++ b/python/tests/web_editing.py @@ -0,0 +1,93 @@ + +import json +import pytest +from fatcat_client.rest import ApiException +from fixtures import * + + +def test_web_release_create_merge(app_admin, api): + + eg = quick_eg(api) + + rv = app_admin.get('/editgroup/{}'.format(eg.editgroup_id)) + assert rv.status_code == 200 + assert b'Release Edits (0)' in rv.data + + # bogus/bad submit + rv = app_admin.post('/release/create', + data={ + 'editgroup_id': eg.editgroup_id, + 'release_type': 'badmojo', + 'release_status': 'published', + 'title': 'something bogus', + }, + follow_redirects=True) + assert rv.status_code == 400 + # Does not insert bad choices into drop-down + #assert b'badmojo' in rv.data + assert b'Not a valid choice' in rv.data + + # ok/valid submit + rv = app_admin.post('/release/create', + data={ + 'editgroup_id': eg.editgroup_id, + 'release_type': 'article-journal', + 'release_status': 'published', + 'title': 'something bogus', + }, + follow_redirects=True) + assert rv.status_code == 200 + + rv = app_admin.get('/editgroup/{}'.format(eg.editgroup_id)) + assert rv.status_code == 200 + assert b'Release Edits (1)' in rv.data + + rv = app_admin.post('/editgroup/{}/submit'.format(eg.editgroup_id), + follow_redirects=True, + ) + assert rv.status_code == 200 + rv = app_admin.get('/editgroup/{}'.format(eg.editgroup_id)) + assert rv.status_code == 200 + assert b'Submitted' in rv.data + assert b'None!' in rv.data + + rv = app_admin.post('/editgroup/{}/annotation'.format(eg.editgroup_id), + data={ + 'comment_markdown': "This is an **example** of markdown in a test annotation", + }, + follow_redirects=True, + ) + assert rv.status_code == 200 + rv = app_admin.get('/editgroup/{}'.format(eg.editgroup_id)) + assert rv.status_code == 200 + assert b'<p>This is an <strong>example</strong> of markdown in a test annotation' in rv.data + + rv = app_admin.post('/editgroup/{}/accept'.format(eg.editgroup_id), + follow_redirects=True, + ) + assert rv.status_code == 200 + rv = app_admin.get('/editgroup/{}'.format(eg.editgroup_id)) + assert rv.status_code == 200 + assert b'Merged' in rv.data + + +def test_web_container_create(app_admin, api): + + eg = quick_eg(api) + + # bogus/bad submit + rv = app_admin.post('/container/create', + data={ + 'editgroup_id': eg.editgroup_id, + }, + follow_redirects=True) + assert rv.status_code == 400 + + # ok/valid submit + rv = app_admin.post('/container/create', + data={ + 'editgroup_id': eg.editgroup_id, + 'name': 'blah blah journal blah', + }, + follow_redirects=True) + assert rv.status_code == 200 |