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/web_entity_views.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'python/tests/web_entity_views.py') diff --git a/python/tests/web_entity_views.py b/python/tests/web_entity_views.py index c1cbdc29..b01bd815 100644 --- a/python/tests/web_entity_views.py +++ b/python/tests/web_entity_views.py @@ -1,4 +1,5 @@ +import json from fixtures import * from fatcat_web.forms import ReleaseEntityForm, FileEntityForm, ContainerEntityForm @@ -25,7 +26,14 @@ REALISTIC_DEMO_ENTITIES = { } -def test_entity_basics(app): +def test_entity_basics(app, mocker): + + es_raw = mocker.patch('elasticsearch.connection.Urllib3HttpConnection.perform_request') + # these are basic ES stats for the container view pages + es_raw.side_effect = [ + (200, {}, json.dumps(ES_CONTAINER_STATS_RESP)), + (200, {}, json.dumps(ES_CONTAINER_RANDOM_RESP)), + ] for entity_type, (ident, revision) in DUMMY_DEMO_ENTITIES.items(): # good requests @@ -132,7 +140,14 @@ def test_lookups(app): assert rv.status_code == 404 -def test_web_container(app): +def test_web_container(app, mocker): + + es_raw = mocker.patch('elasticsearch.connection.Urllib3HttpConnection.perform_request') + # these are basic ES stats for the container view pages + es_raw.side_effect = [ + (200, {}, json.dumps(ES_CONTAINER_STATS_RESP)), + (200, {}, json.dumps(ES_CONTAINER_RANDOM_RESP)), + ] rv = app.get('/container/aaaaaaaaaaaaaeiraaaaaaaaai') assert rv.status_code == 200 -- cgit v1.2.3