From eb9e9fac3bf5c235822b5dd76f30f9d478adbc0c Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Tue, 17 Jul 2018 17:02:59 +0100 Subject: [PATCH] Ensure one-off jobs do not appear on message log page Upcoming changes to API will mean that by default its `get_notifications_for_service` DAO function will return one-off notifications. In most cases this is what we want, but the message log page should not show one-off notifications. By passing in the `include_one_off=False` option to API we can ensure that this page will stay the same when API changes. --- app/notify_client/notification_api_client.py | 10 +++++++++- tests/conftest.py | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/notify_client/notification_api_client.py b/app/notify_client/notification_api_client.py index 6f903e835..187162e68 100644 --- a/app/notify_client/notification_api_client.py +++ b/app/notify_client/notification_api_client.py @@ -18,6 +18,7 @@ class NotificationApiClient(NotifyAdminAPIClient): include_from_test_key=None, format_for_csv=None, to=None, + include_one_off=None, ): params = {} if page is not None: @@ -36,6 +37,8 @@ class NotificationApiClient(NotifyAdminAPIClient): params['format_for_csv'] = format_for_csv if to is not None: params['to'] = to + if include_one_off is not None: + params['include_one_off'] = include_one_off if job_id: return self.get( url='/service/{}/job/{}/notifications'.format(service_id, job_id), @@ -64,7 +67,12 @@ class NotificationApiClient(NotifyAdminAPIClient): return self.get(url='/service/{}/notifications/{}'.format(service_id, notification_id)) def get_api_notifications_for_service(self, service_id): - ret = self.get_notifications_for_service(service_id, include_jobs=False, include_from_test_key=True) + ret = self.get_notifications_for_service( + service_id, + include_jobs=False, + include_from_test_key=True, + include_one_off=False + ) return self.map_letters_to_accepted(ret) @staticmethod diff --git a/tests/conftest.py b/tests/conftest.py index f9cb681c5..513c2fe39 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1810,6 +1810,7 @@ def mock_get_notifications( include_jobs=None, include_from_test_key=None, to=None, + include_one_off=None, ): job = None if job_id is not None: @@ -1858,6 +1859,7 @@ def mock_get_notifications_with_previous_next(mocker): include_jobs=None, include_from_test_key=None, to=None, + include_one_off=None ): return notification_json(service_id, with_links=True) @@ -1878,6 +1880,7 @@ def mock_get_notifications_with_no_notifications(mocker): include_jobs=None, include_from_test_key=None, to=None, + include_one_off=None ): return notification_json(service_id, rows=0)