mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-03 07:31:28 -04:00
pass 'today_only' flag to the back-end from send page
also bump notification-utils requirement to 8.7.0 for changes to RecipientCSV
This commit is contained in:
@@ -42,13 +42,13 @@ class ServiceAPIClient(NotificationsAPIClient):
|
||||
return self.delete(endpoint, data)
|
||||
|
||||
def get_service(self, service_id):
|
||||
return self._get_service(service_id, False, today_only=False)
|
||||
return self._get_service(service_id, detailed=False, today_only=False)
|
||||
|
||||
def get_detailed_service(self, service_id):
|
||||
return self._get_service(service_id, True, today_only=False)
|
||||
return self._get_service(service_id, detailed=True, today_only=False)
|
||||
|
||||
def get_detailed_service_for_today(self, service_id):
|
||||
return self._get_service(service_id, False, today_only=True)
|
||||
return self._get_service(service_id, detailed=True, today_only=True)
|
||||
|
||||
def _get_service(self, service_id, detailed, today_only):
|
||||
"""
|
||||
@@ -57,7 +57,12 @@ class ServiceAPIClient(NotificationsAPIClient):
|
||||
:param detailed - return additional details, including notification statistics
|
||||
:param today_only - return statistics only for today. No effect if detailed not passed in
|
||||
"""
|
||||
params = {'detailed': True} if detailed else {}
|
||||
params = {}
|
||||
if detailed:
|
||||
params['detailed'] = detailed
|
||||
if today_only:
|
||||
params['today_only'] = today_only
|
||||
|
||||
return self.get(
|
||||
'/service/{0}'.format(service_id),
|
||||
params=params)
|
||||
|
||||
@@ -19,4 +19,4 @@ pytz==2016.4
|
||||
|
||||
git+https://github.com/alphagov/notifications-python-client.git@1.0.0#egg=notifications-python-client==1.0.0
|
||||
|
||||
git+https://github.com/alphagov/notifications-utils.git@8.4.2#egg=notifications-utils==8.4.2
|
||||
git+https://github.com/alphagov/notifications-utils.git@8.7.0#egg=notifications-utils==8.7.0
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from app.notify_client.service_api_client import ServiceAPIClient
|
||||
from tests.conftest import fake_uuid
|
||||
|
||||
@@ -21,17 +23,17 @@ def test_client_posts_archived_true_when_deleting_template(mocker):
|
||||
mock_post.assert_called_once_with(expected_url, data=expected_data)
|
||||
|
||||
|
||||
def test_client_gets_service_with_no_params(mocker):
|
||||
@pytest.mark.parametrize(
|
||||
'function,params', [
|
||||
(ServiceAPIClient.get_service, {}),
|
||||
(ServiceAPIClient.get_detailed_service, {'detailed': True}),
|
||||
(ServiceAPIClient.get_detailed_service_for_today, {'detailed': True, 'today_only': True})
|
||||
],
|
||||
ids=lambda x: x.__name__
|
||||
)
|
||||
def test_client_gets_service(mocker, function, params):
|
||||
client = ServiceAPIClient()
|
||||
mock_post = mocker.patch('app.notify_client.service_api_client.ServiceAPIClient.get')
|
||||
mock_post = mocker.patch.object(client, 'get')
|
||||
|
||||
client.get_service('foo')
|
||||
mock_post.assert_called_once_with('/service/foo', params={})
|
||||
|
||||
|
||||
def test_client_gets_service_with_detailed_params(mocker):
|
||||
client = ServiceAPIClient()
|
||||
mock_post = mocker.patch('app.notify_client.service_api_client.ServiceAPIClient.get')
|
||||
|
||||
client.get_detailed_service('foo')
|
||||
mock_post.assert_called_once_with('/service/foo', params={'detailed': True})
|
||||
function(client, 'foo')
|
||||
mock_post.assert_called_once_with('/service/foo', params=params)
|
||||
|
||||
Reference in New Issue
Block a user