diff options
Diffstat (limited to 'python/tests/subentity_state.py')
-rw-r--r-- | python/tests/subentity_state.py | 76 |
1 files changed, 40 insertions, 36 deletions
diff --git a/python/tests/subentity_state.py b/python/tests/subentity_state.py index 2843176d..fda4b582 100644 --- a/python/tests/subentity_state.py +++ b/python/tests/subentity_state.py @@ -1,4 +1,3 @@ - import json from fatcat_openapi_client import * @@ -19,6 +18,7 @@ Current set of such references: => work -> release """ + def test_relation_states(api, app, mocker): j1 = ContainerEntity(name="test journal") @@ -31,14 +31,14 @@ def test_relation_states(api, app, mocker): # WIP container # these are basic ES stats for the container view pages - es_raw = mocker.patch('elasticsearch.connection.Urllib3HttpConnection.perform_request') + es_raw = mocker.patch("elasticsearch.connection.Urllib3HttpConnection.perform_request") es_raw.side_effect = [ (200, {}, json.dumps(ES_CONTAINER_STATS_RESP)), (200, {}, json.dumps(ES_CONTAINER_RANDOM_RESP)), ] eg = quick_eg(api) j2 = api.get_container(api.create_container(eg.editgroup_id, j2).ident) - rv = app.get('/container/{}'.format(j2.ident)) + rv = app.get("/container/{}".format(j2.ident)) assert rv.status_code == 200 # create inter-related entities @@ -59,15 +59,15 @@ def test_relation_states(api, app, mocker): assert r1.contribs[0].creator_id == c1.ident assert r1.contribs[0].creator.display_name == "test person" assert r1.contribs[0].creator.state == "active" - rv = app.get('/release/{}'.format(r1.ident)) + rv = app.get("/release/{}".format(r1.ident)) assert rv.status_code == 200 # delete creator eg = quick_eg(api) api.delete_creator(eg.editgroup_id, c1.ident) api.accept_editgroup(eg.editgroup_id) - rv = app.get('/creator/{}'.format(c1.ident)) - assert rv.status_code == 200 # TODO: HTTP status "Gone"? + rv = app.get("/creator/{}".format(c1.ident)) + assert rv.status_code == 200 # TODO: HTTP status "Gone"? c1_deleted = api.get_creator(c1.ident) assert c1_deleted.state == "deleted" @@ -79,7 +79,7 @@ def test_relation_states(api, app, mocker): assert r1.contribs[0].creator_id == c1.ident assert r1.contribs[0].creator.display_name is None assert r1.contribs[0].creator.state == "deleted" - rv = app.get('/release/{}'.format(r1.ident)) + rv = app.get("/release/{}".format(r1.ident)) assert rv.status_code == 200 # wip container @@ -96,14 +96,16 @@ def test_relation_states(api, app, mocker): assert r1.contribs[0].creator_id == c1.ident assert r1.contribs[0].creator.display_name is None assert r1.contribs[0].creator.state == "deleted" - rv = app.get('/release/{}'.format(r1.ident)) + rv = app.get("/release/{}".format(r1.ident)) assert rv.status_code == 200 # redirect release r2 = api.get_release(r2.ident, expand="container,creators,files") assert r2.files == [] eg = quick_eg(api) - api.update_release(eg.editgroup_id, r2.ident, ReleaseEntity(redirect=r1.ident, ext_ids=ReleaseExtIds())) + api.update_release( + eg.editgroup_id, r2.ident, ReleaseEntity(redirect=r1.ident, ext_ids=ReleaseExtIds()) + ) f2.release_ids = [r2.ident] f2 = api.get_file(api.create_file(eg.editgroup_id, f2).ident) api.accept_editgroup(eg.editgroup_id) @@ -116,9 +118,9 @@ def test_relation_states(api, app, mocker): assert r2.contribs[0].creator_id == c1.ident assert r2.contribs[0].creator.display_name is None assert r2.contribs[0].creator.state == "deleted" - rv = app.get('/release/{}'.format(r2.ident)) + rv = app.get("/release/{}".format(r2.ident)) assert rv.status_code == 302 - rv = app.get('/file/{}'.format(f2.ident)) + rv = app.get("/file/{}".format(f2.ident)) assert rv.status_code == 200 # delete release @@ -130,9 +132,9 @@ def test_relation_states(api, app, mocker): assert r2.container is None assert r2.files is None assert r2.contribs is None - rv = app.get('/release/{}'.format(r2.ident)) - assert rv.status_code == 200 # TODO: HTTP Gone? - rv = app.get('/file/{}'.format(f2.ident)) + rv = app.get("/release/{}".format(r2.ident)) + assert rv.status_code == 200 # TODO: HTTP Gone? + rv = app.get("/file/{}".format(f2.ident)) print(rv.data) assert rv.status_code == 200 @@ -140,7 +142,7 @@ def test_relation_states(api, app, mocker): def test_app_entity_states(api, app, mocker): # these are basic ES stats for the container view pages - es_raw = mocker.patch('elasticsearch.connection.Urllib3HttpConnection.perform_request') + es_raw = mocker.patch("elasticsearch.connection.Urllib3HttpConnection.perform_request") es_raw.side_effect = [ (200, {}, json.dumps(ES_CONTAINER_STATS_RESP)), (200, {}, json.dumps(ES_CONTAINER_RANDOM_RESP)), @@ -175,30 +177,32 @@ def test_app_entity_states(api, app, mocker): api.update_container(eg.editgroup_id, j2.ident, ContainerEntity(redirect=j1.ident)) api.update_creator(eg.editgroup_id, c2.ident, CreatorEntity(redirect=c1.ident)) api.update_file(eg.editgroup_id, f2.ident, FileEntity(redirect=f1.ident)) - api.update_release(eg.editgroup_id, r2.ident, ReleaseEntity(redirect=r1.ident, ext_ids=ReleaseExtIds())) + api.update_release( + eg.editgroup_id, r2.ident, ReleaseEntity(redirect=r1.ident, ext_ids=ReleaseExtIds()) + ) api.update_work(eg.editgroup_id, r2.work_id, WorkEntity(redirect=r1.work_id)) api.accept_editgroup(eg.editgroup_id) # all entities - rv = app.get('/container/{}'.format(j1.ident)) + rv = app.get("/container/{}".format(j1.ident)) assert rv.status_code == 200 - rv = app.get('/container/{}'.format(j2.ident)) + rv = app.get("/container/{}".format(j2.ident)) assert rv.status_code == 302 - rv = app.get('/creator/{}'.format(c1.ident)) + rv = app.get("/creator/{}".format(c1.ident)) assert rv.status_code == 200 - rv = app.get('/creator/{}'.format(c2.ident)) + rv = app.get("/creator/{}".format(c2.ident)) assert rv.status_code == 302 - rv = app.get('/file/{}'.format(f1.ident)) + rv = app.get("/file/{}".format(f1.ident)) assert rv.status_code == 200 - rv = app.get('/file/{}'.format(f2.ident)) + rv = app.get("/file/{}".format(f2.ident)) assert rv.status_code == 302 - rv = app.get('/release/{}'.format(r1.ident)) + rv = app.get("/release/{}".format(r1.ident)) assert rv.status_code == 200 - rv = app.get('/release/{}'.format(r2.ident)) + rv = app.get("/release/{}".format(r2.ident)) assert rv.status_code == 302 - rv = app.get('/work/{}'.format(r1.work_id)) + rv = app.get("/work/{}".format(r1.work_id)) assert rv.status_code == 200 - rv = app.get('/work/{}'.format(r2.work_id)) + rv = app.get("/work/{}".format(r2.work_id)) assert rv.status_code == 302 # delete targets @@ -211,23 +215,23 @@ def test_app_entity_states(api, app, mocker): api.accept_editgroup(eg.editgroup_id) # all entities - rv = app.get('/container/{}'.format(j1.ident)) + rv = app.get("/container/{}".format(j1.ident)) assert rv.status_code == 200 - rv = app.get('/container/{}'.format(j2.ident)) + rv = app.get("/container/{}".format(j2.ident)) assert rv.status_code == 302 - rv = app.get('/creator/{}'.format(c1.ident)) + rv = app.get("/creator/{}".format(c1.ident)) assert rv.status_code == 200 - rv = app.get('/creator/{}'.format(c2.ident)) + rv = app.get("/creator/{}".format(c2.ident)) assert rv.status_code == 302 - rv = app.get('/file/{}'.format(f1.ident)) + rv = app.get("/file/{}".format(f1.ident)) assert rv.status_code == 200 - rv = app.get('/file/{}'.format(f2.ident)) + rv = app.get("/file/{}".format(f2.ident)) assert rv.status_code == 302 - rv = app.get('/release/{}'.format(r1.ident)) + rv = app.get("/release/{}".format(r1.ident)) assert rv.status_code == 200 - rv = app.get('/release/{}'.format(r2.ident)) + rv = app.get("/release/{}".format(r2.ident)) assert rv.status_code == 302 - rv = app.get('/work/{}'.format(r1.work_id)) + rv = app.get("/work/{}".format(r1.work_id)) assert rv.status_code == 200 - rv = app.get('/work/{}'.format(r2.work_id)) + rv = app.get("/work/{}".format(r2.work_id)) assert rv.status_code == 302 |