mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 17:45:32 -04:00
Add new methods to Service and Complaint api clients
* Added a new method to the ComplaintApiClient to get the total complaints by date range from the API. * Added a new method to the ServiceAPIClient to get the new platform admin stats data from the API.
This commit is contained in:
@@ -9,3 +9,6 @@ class ComplaintApiClient(NotifyAdminAPIClient):
|
|||||||
|
|
||||||
def get_all_complaints(self):
|
def get_all_complaints(self):
|
||||||
return self.get('/complaint')
|
return self.get('/complaint')
|
||||||
|
|
||||||
|
def get_complaint_count(self, params_dict=None):
|
||||||
|
return self.get('/complaint/count-by-date-range', params=params_dict)
|
||||||
|
|||||||
@@ -409,6 +409,9 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
|||||||
def get_aggregate_platform_stats(self, params_dict=None):
|
def get_aggregate_platform_stats(self, params_dict=None):
|
||||||
return self.get("/service/platform-stats", params=params_dict)
|
return self.get("/service/platform-stats", params=params_dict)
|
||||||
|
|
||||||
|
def get_new_aggregate_platform_stats(self, params_dict=None):
|
||||||
|
return self.get("/service/platform-stats-new", params=params_dict)
|
||||||
|
|
||||||
def get_sms_senders(self, service_id):
|
def get_sms_senders(self, service_id):
|
||||||
return self.get(
|
return self.get(
|
||||||
"/service/{}/sms-sender".format(service_id)
|
"/service/{}/sms-sender".format(service_id)
|
||||||
|
|||||||
@@ -8,3 +8,12 @@ def test_get_all_complaints(mocker):
|
|||||||
|
|
||||||
client.get_all_complaints()
|
client.get_all_complaints()
|
||||||
mock.assert_called_once_with('/complaint')
|
mock.assert_called_once_with('/complaint')
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_complaint_count(mocker):
|
||||||
|
client = ComplaintApiClient()
|
||||||
|
mock = mocker.patch.object(client, 'get')
|
||||||
|
params_dict = {'start_date': '2018-06-01', 'end_date': '2018-06-15'}
|
||||||
|
|
||||||
|
client.get_complaint_count(params_dict=params_dict)
|
||||||
|
mock.assert_called_once_with('/complaint/count-by-date-range', params=params_dict)
|
||||||
|
|||||||
@@ -53,6 +53,15 @@ def test_client_only_updates_allowed_attributes(mocker):
|
|||||||
assert str(error.value) == 'Not allowed to update service attributes: foo'
|
assert str(error.value) == 'Not allowed to update service attributes: foo'
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_new_aggregate_platform_stats(mocker):
|
||||||
|
client = ServiceAPIClient()
|
||||||
|
mock = mocker.patch.object(client, 'get')
|
||||||
|
params_dict = {'start_date': '2018-06-01', 'end_date': '2018-06-15'}
|
||||||
|
|
||||||
|
client.get_new_aggregate_platform_stats(params_dict=params_dict)
|
||||||
|
mock.assert_called_once_with('/service/platform-stats-new', params=params_dict)
|
||||||
|
|
||||||
|
|
||||||
def test_client_creates_service_with_correct_data(
|
def test_client_creates_service_with_correct_data(
|
||||||
mocker,
|
mocker,
|
||||||
active_user_with_permissions,
|
active_user_with_permissions,
|
||||||
|
|||||||
Reference in New Issue
Block a user