From 62a09c52230df88782d71963236a9a4e86e2cbb5 Mon Sep 17 00:00:00 2001 From: Andrew Shumway Date: Fri, 27 Oct 2023 10:00:45 -0600 Subject: [PATCH] Added mock to client request for get request of count --- app/__init__.py | 8 ++++++-- tests/conftest.py | 11 +++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 42d585ac6..a8f439fe3 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -290,8 +290,12 @@ def init_app(application): if service_id: global_limit = current_app.config["GLOBAL_SERVICE_MESSAGE_LIMIT"] - global_messages_count = service_api_client.get_global_notification_count(service_id) - remaining_global_messages = global_limit - global_messages_count.get("count") + global_messages_count = ( + service_api_client.get_global_notification_count(service_id) + ) + remaining_global_messages = global_limit - global_messages_count.get( + "count" + ) return {"daily_global_messages_remaining": remaining_global_messages} @application.before_request diff --git a/tests/conftest.py b/tests/conftest.py index 8b552a8fd..fac5d64d4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2423,8 +2423,15 @@ def _os_environ(): os.environ[k] = v -@pytest.fixture() -def client_request(logged_in_client, mocker, service_one): # noqa (C901 too complex) +@pytest.fixture() # noqa (C901 too complex) +def client_request(_logged_in_client, mocker, service_one): # noqa (C901 too complex) + def _get(mocker): + return {"count": 0} + + mocker.patch( + "app.service_api_client.get_global_notification_count", side_effect=_get + ) + class ClientRequest: @staticmethod @contextmanager