From 77c2aa9fd63b010d3f0d2ee6a62fec12b61ff0b2 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Mon, 28 Jun 2021 10:11:22 +0100 Subject: [PATCH] Stop passing in `today_only` for the get_service_statistics method. We now only ever call it with False. To remove it from the api call will require a change in the API so will do that at another time. --- app/main/views/jobs.py | 1 - app/notify_client/service_api_client.py | 6 ++---- tests/app/notify_client/test_service_api_client.py | 13 ++++--------- tests/conftest.py | 2 +- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index fe86ad1c4..e667fcae6 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -272,7 +272,6 @@ def get_notifications(service_id, message_type, status_override=None): message_type, service_api_client.get_service_statistics( service_id, - today_only=False, limit_days=service_data_retention_days ) ) diff --git a/app/notify_client/service_api_client.py b/app/notify_client/service_api_client.py index 81eafa4f2..3be73ad38 100644 --- a/app/notify_client/service_api_client.py +++ b/app/notify_client/service_api_client.py @@ -43,10 +43,8 @@ class ServiceAPIClient(NotifyAdminAPIClient): """ return self.get('/service/{0}'.format(service_id)) - def get_service_statistics(self, service_id, today_only, limit_days=None): - return self.get('/service/{0}/statistics'.format(service_id), params={ - 'today_only': today_only, 'limit_days': limit_days - })['data'] + def get_service_statistics(self, service_id, limit_days=None): + return self.get('/service/{0}/statistics'.format(service_id), params={'limit_days': limit_days})['data'] def get_services(self, params_dict=None): """ diff --git a/tests/app/notify_client/test_service_api_client.py b/tests/app/notify_client/test_service_api_client.py index 3cc128a1b..eae5a3ee5 100644 --- a/tests/app/notify_client/test_service_api_client.py +++ b/tests/app/notify_client/test_service_api_client.py @@ -37,20 +37,15 @@ def test_client_gets_service(mocker): mock_get.assert_called_once_with('/service/foo') -@pytest.mark.parametrize('today_only, limit_days', [ - (False, None), - (False, 30), -]) -def test_client_gets_service_statistics(mocker, today_only, limit_days): +@pytest.mark.parametrize('limit_days', [None, 30]) +def test_client_gets_service_statistics(mocker, limit_days): client = ServiceAPIClient() mock_get = mocker.patch.object(client, 'get', return_value={'data': {'a': 'b'}}) - ret = client.get_service_statistics('foo', today_only, limit_days) + ret = client.get_service_statistics('foo', limit_days) assert ret == {'a': 'b'} - mock_get.assert_called_once_with('/service/foo/statistics', params={ - 'today_only': today_only, 'limit_days': limit_days - }) + mock_get.assert_called_once_with('/service/foo/statistics', params={'limit_days': limit_days}) def test_client_only_updates_allowed_attributes(mocker): diff --git a/tests/conftest.py b/tests/conftest.py index ab5f83e56..fa4a12434 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -502,7 +502,7 @@ def mock_get_service(mocker, api_user_active): @pytest.fixture(scope='function') def mock_get_service_statistics(mocker, api_user_active): - def _get(service_id, today_only, limit_days=None): + def _get(service_id, limit_days=None): return { 'email': {'requested': 0, 'delivered': 0, 'failed': 0}, 'sms': {'requested': 0, 'delivered': 0, 'failed': 0},