Add additional params to get notifications client

We want to show a log of notifications that have been sent from the API.

The admin app uses its own private `/service/…/notifications` endpoint
for listing activity. This commit allows us to pass through two
optional, additional parameters to tell the API to:

- include or not include notifications created from a job
- include or not include notifications created with a test API key
This commit is contained in:
Chris Hill-Scott
2016-09-21 09:32:20 +01:00
parent ce0b3511e6
commit a04aad8825
3 changed files with 18 additions and 2 deletions

View File

@@ -27,7 +27,9 @@ class NotificationApiClient(BaseAPIClient):
status=None,
page=None,
page_size=None,
limit_days=None
limit_days=None,
include_jobs=None,
include_from_test_key=None
):
params = {}
if page is not None:
@@ -38,6 +40,10 @@ class NotificationApiClient(BaseAPIClient):
params['template_type'] = template_type
if status is not None:
params['status'] = status
if include_jobs is not None:
params['include_jobs'] = include_jobs
if include_from_test_key is not None:
params['include_from_test_key'] = include_from_test_key
if job_id:
return self.get(
url='/service/{}/job/{}/notifications'.format(service_id, job_id),

View File

@@ -25,6 +25,14 @@ def test_client_gets_notifications_with_page(mocker):
{'page': 99},
{'url': '/service/abcd1234/notifications', 'params': {'page': 99}}
),
(
{'include_jobs': False},
{'url': '/service/abcd1234/notifications', 'params': {'include_jobs': False}}
),
(
{'include_from_test_key': True},
{'url': '/service/abcd1234/notifications', 'params': {'include_from_test_key': True}}
),
(
{'job_id': 'efgh5678'},
{'url': '/service/abcd1234/job/efgh5678/notifications', 'params': {}}

View File

@@ -938,7 +938,9 @@ def mock_get_notifications(mocker, api_user_active):
limit_days=None,
rows=5,
set_template_type=None,
set_status=None
set_status=None,
include_jobs=None,
include_from_test_key=None
):
job = None
if job_id is not None: