diff --git a/app/notify_client/job_api_client.py b/app/notify_client/job_api_client.py index 34b9e2088..fa129b5d5 100644 --- a/app/notify_client/job_api_client.py +++ b/app/notify_client/job_api_client.py @@ -71,16 +71,6 @@ class JobApiClient(BaseAPIClient): data = _attach_current_user(data) job = self.post(url='/service/{}/job'.format(service_id), data=data) - stats = self.__convert_statistics(job) - job['data']['notifications_sent'] = stats['delivered'] + stats['failed'] - job['data']['notifications_delivered'] = stats['delivered'] - job['data']['notifications_failed'] = stats['failed'] - - if scheduled_for: - data.update({'scheduled_for': scheduled_for}) - data = _attach_current_user(data) - job = self.post(url='/service/{}/job'.format(service_id), data=data) - stats = self.__convert_statistics(job['data']) job['data']['notifications_sent'] = stats['delivered'] + stats['failed'] job['data']['notifications_delivered'] = stats['delivered'] diff --git a/tests/__init__.py b/tests/__init__.py index affd30e97..a3cb0da0c 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -178,6 +178,7 @@ def job_json( 'notifications_sent': notifications_sent, 'notifications_requested': notifications_requested, 'job_status': job_status, + 'statistics': [], 'created_by': created_by_json( created_by.id, created_by.name, diff --git a/tests/app/notify_client/test_job_client.py b/tests/app/notify_client/test_job_client.py index b65d4006e..473bf6f89 100644 --- a/tests/app/notify_client/test_job_client.py +++ b/tests/app/notify_client/test_job_client.py @@ -97,42 +97,6 @@ def test_client_gets_job_by_service_filtered_by_status(mocker): mock_get.assert_called_once_with(url=expected_url, params={'limit_days': 1}) -def test_client_parses_handles_no_statistics_on_job_when_no_rows_processed(mocker): - mocker.patch('app.notify_client.current_user', id='1') - - service_id = 'service_id' - job_id = 'job_id' - expected_data = {'data': { - 'status': 'finished', - 'template_version': 3, - 'id': job_id, - 'updated_at': '2016-08-24T08:29:28.332972+00:00', - 'service': service_id, - 'processing_finished': '2016-08-24T08:11:48.676365+00:00', - 'original_file_name': 'test-notify-email.csv', - 'created_by': { - 'name': 'test-user@digital.cabinet-office.gov.uk', - 'id': '3571f2ae-7a39-4fb4-9ad7-8453f5257072' - }, - 'created_at': '2016-08-24T08:09:56.371073+00:00', - 'template': 'c0309261-9c9e-4530-8fed-5f67b02260d2', - 'notification_count': 30, - 'processing_started': '2016-08-24T08:09:57.661246+00:00' - }} - - expected_url = '/service/{}/job/{}'.format(service_id, job_id) - - client = JobApiClient() - mock_get = mocker.patch('app.notify_client.job_api_client.JobApiClient.get', return_value=expected_data) - - result = client.get_job(service_id, job_id) - - mock_get.assert_called_once_with(url=expected_url, params={}) - assert result['data']['notifications_sent'] == 0 - assert result['data']['notification_count'] == 30 - assert result['data']['notifications_failed'] == 0 - - def test_client_parses_job_stats(mocker): mocker.patch('app.notify_client.current_user', id='1')