mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-12 13:20:43 -04:00
Extra test for the zero stats case
This commit is contained in:
@@ -159,6 +159,43 @@ def test_client_parses_job_stats(mocker):
|
||||
assert result['data']['notifications_failed'] == 40
|
||||
|
||||
|
||||
def test_client_parses_empty_job_stats(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',
|
||||
'statistics': [],
|
||||
'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': 80,
|
||||
'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'] == 80
|
||||
assert result['data']['notifications_failed'] == 0
|
||||
|
||||
|
||||
def test_client_parses_job_stats_for_service(mocker):
|
||||
mocker.patch('app.notify_client.current_user', id='1')
|
||||
|
||||
@@ -235,3 +272,63 @@ def test_client_parses_job_stats_for_service(mocker):
|
||||
assert result['data'][1]['notifications_sent'] == 25
|
||||
assert result['data'][1]['notification_count'] == 40
|
||||
assert result['data'][1]['notifications_failed'] == 20
|
||||
|
||||
|
||||
def test_client_parses_empty_job_stats_for_service(mocker):
|
||||
mocker.patch('app.notify_client.current_user', id='1')
|
||||
|
||||
service_id = 'service_id'
|
||||
job_1_id = 'job_id_1'
|
||||
job_2_id = 'job_id_2'
|
||||
expected_data = {'data': [{
|
||||
'status': 'finished',
|
||||
'template_version': 3,
|
||||
'id': job_1_id,
|
||||
'updated_at': '2016-08-24T08:29:28.332972+00:00',
|
||||
'service': service_id,
|
||||
'processing_finished': '2016-08-24T08:11:48.676365+00:00',
|
||||
'statistics': [],
|
||||
'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': 80,
|
||||
'processing_started': '2016-08-24T08:09:57.661246+00:00'
|
||||
}, {
|
||||
'status': 'finished',
|
||||
'template_version': 3,
|
||||
'id': job_2_id,
|
||||
'updated_at': '2016-08-24T08:29:28.332972+00:00',
|
||||
'service': service_id,
|
||||
'processing_finished': '2016-08-24T08:11:48.676365+00:00',
|
||||
'statistics': [],
|
||||
'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': 40,
|
||||
'processing_started': '2016-08-24T08:09:57.661246+00:00'
|
||||
}]}
|
||||
|
||||
expected_url = '/service/{}/job'.format(service_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)
|
||||
|
||||
mock_get.assert_called_once_with(url=expected_url, params={})
|
||||
assert result['data'][0]['id'] == job_1_id
|
||||
assert result['data'][0]['notifications_sent'] == 0
|
||||
assert result['data'][0]['notification_count'] == 80
|
||||
assert result['data'][0]['notifications_failed'] == 0
|
||||
assert result['data'][1]['id'] == job_2_id
|
||||
assert result['data'][1]['notifications_sent'] == 0
|
||||
assert result['data'][1]['notification_count'] == 40
|
||||
assert result['data'][1]['notifications_failed'] == 0
|
||||
|
||||
Reference in New Issue
Block a user