From 1f6f9c0e251f45f220dd48242d48fa61922fe55f Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 24 Jul 2020 13:00:04 -0700 Subject: refactor coverage tests/mocks --- python/tests/subentity_state.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'python/tests/subentity_state.py') diff --git a/python/tests/subentity_state.py b/python/tests/subentity_state.py index e03fa99e..2843176d 100644 --- a/python/tests/subentity_state.py +++ b/python/tests/subentity_state.py @@ -1,4 +1,6 @@ +import json + from fatcat_openapi_client import * from fixtures import * @@ -17,7 +19,7 @@ Current set of such references: => work -> release """ -def test_relation_states(api, app): +def test_relation_states(api, app, mocker): j1 = ContainerEntity(name="test journal") j2 = ContainerEntity(name="another test journal") @@ -28,6 +30,12 @@ def test_relation_states(api, app): f2 = FileEntity(md5="0000000000000000ad9d7b45268be409") # WIP container + # these are basic ES stats for the container view pages + 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)) @@ -129,7 +137,14 @@ def test_relation_states(api, app): assert rv.status_code == 200 -def test_app_entity_states(api, app): +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.side_effect = [ + (200, {}, json.dumps(ES_CONTAINER_STATS_RESP)), + (200, {}, json.dumps(ES_CONTAINER_RANDOM_RESP)), + ] j1 = ContainerEntity(name="test journal") j2 = ContainerEntity(name="another test journal") -- cgit v1.2.3