mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-06 11:23:48 -05:00
Revert "Job stats table"
This commit is contained in:
@@ -22,7 +22,6 @@ Brew is a package manager for OSX. The following command installs brew:
|
||||
|
||||
Languages needed
|
||||
- Python 3.4
|
||||
- [pip] (https://pip.pypa.io/en/stable/installing/)
|
||||
- [Node](https://nodejs.org/) 5.0.0 or greater
|
||||
- [npm](https://www.npmjs.com/) 3.0.0 or greater
|
||||
```shell
|
||||
@@ -35,7 +34,7 @@ different versions of Node. The following installs `n` and uses the latest
|
||||
version of Node.
|
||||
```shell
|
||||
npm install -g n
|
||||
sudo n latest
|
||||
n latest
|
||||
npm rebuild node-sass
|
||||
```
|
||||
|
||||
|
||||
@@ -55,13 +55,13 @@ class JobApiClient(NotifyAdminAPIClient):
|
||||
if statuses is not None:
|
||||
params['statuses'] = ','.join(statuses)
|
||||
|
||||
jobs = self.get(url='/service/{}/job/job-stats'.format(service_id), params=params)
|
||||
|
||||
jobs = self.get(url='/service/{}/job'.format(service_id), params=params)
|
||||
for job in jobs['data']:
|
||||
job['notifications_delivered'] = job['delivered']
|
||||
job['notifications_failed'] = job['failed']
|
||||
job['notification_count'] = job['sent']
|
||||
job['id'] = job['job_id']
|
||||
stats = self.__convert_statistics(job)
|
||||
job['notifications_sent'] = stats['delivered'] + stats['failed']
|
||||
job['notifications_delivered'] = stats['delivered']
|
||||
job['notifications_failed'] = stats['failed']
|
||||
job['notifications_requested'] = stats['requested']
|
||||
|
||||
return jobs
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ def test_client_creates_job_data_correctly(mocker, fake_uuid):
|
||||
|
||||
|
||||
def test_client_schedules_job(mocker, fake_uuid):
|
||||
|
||||
mocker.patch('app.notify_client.current_user', id='1')
|
||||
|
||||
mock_post = mocker.patch('app.notify_client.job_api_client.JobApiClient.post')
|
||||
@@ -168,43 +169,61 @@ def test_client_parses_job_stats_for_service(mocker):
|
||||
service_id = 'service_id'
|
||||
job_1_id = 'job_id_1'
|
||||
job_2_id = 'job_id_2'
|
||||
|
||||
expected_data = {'data': [{
|
||||
'original_file_name': 'email job.ods',
|
||||
'delivered': 15,
|
||||
'notification_count': 11,
|
||||
'sent': 30,
|
||||
'template_id': 'some_id',
|
||||
'template_version': 1,
|
||||
'notifications_failed': 0,
|
||||
'scheduled_for': None,
|
||||
'job_status': 'finished',
|
||||
'created_at': '2017-08-15T10:57:57.702936Z',
|
||||
'id': service_id,
|
||||
'job_id': job_1_id,
|
||||
'notifications_delivered': 1,
|
||||
'failed': 21,
|
||||
'service_id': service_id,
|
||||
'requested': 1},
|
||||
{'original_file_name': 'email job.ods',
|
||||
'delivered': 12,
|
||||
'notification_count': 1,
|
||||
'sent': 77,
|
||||
'template_id': 'some_id',
|
||||
'template_version': 1,
|
||||
'notifications_failed': 0,
|
||||
'scheduled_for': None,
|
||||
'job_status': 'finished',
|
||||
'created_at': '2017-08-15T10:17:06.731181Z',
|
||||
'id': service_id,
|
||||
'job_id': job_2_id,
|
||||
'notifications_delivered': 12,
|
||||
'failed': 5,
|
||||
'service_id': '66febfde-1df1-4524-9724-5b5856472f88',
|
||||
'requested': 1}],
|
||||
'links': {}, 'total': 4, 'page_size': 50}
|
||||
'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': [
|
||||
{'status': 'failed', 'count': 10},
|
||||
{'status': 'technical-failure', 'count': 10},
|
||||
{'status': 'temporary-failure', 'count': 10},
|
||||
{'status': 'permanent-failure', 'count': 10},
|
||||
{'status': 'created', 'count': 10},
|
||||
{'status': 'sending', 'count': 10},
|
||||
{'status': 'pending', 'count': 10},
|
||||
{'status': 'delivered', 'count': 10}
|
||||
],
|
||||
'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': [
|
||||
{'status': 'failed', 'count': 5},
|
||||
{'status': 'technical-failure', 'count': 5},
|
||||
{'status': 'temporary-failure', 'count': 5},
|
||||
{'status': 'permanent-failure', 'count': 5},
|
||||
{'status': 'created', 'count': 5},
|
||||
{'status': 'sending', 'count': 5},
|
||||
{'status': 'pending', 'count': 5},
|
||||
{'status': 'delivered', 'count': 5}
|
||||
],
|
||||
'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/job-stats'.format(service_id)
|
||||
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)
|
||||
@@ -213,56 +232,58 @@ def test_client_parses_job_stats_for_service(mocker):
|
||||
|
||||
mock_get.assert_called_once_with(url=expected_url, params={'page': 1})
|
||||
assert result['data'][0]['id'] == job_1_id
|
||||
assert result['data'][0]['notifications_delivered'] == 15
|
||||
assert result['data'][0]['notification_count'] == 30
|
||||
assert result['data'][0]['notifications_failed'] == 21
|
||||
assert result['data'][0]['notifications_requested'] == 80
|
||||
assert result['data'][0]['notifications_sent'] == 50
|
||||
assert result['data'][0]['notification_count'] == 80
|
||||
assert result['data'][0]['notifications_failed'] == 40
|
||||
assert result['data'][1]['id'] == job_2_id
|
||||
assert result['data'][1]['notifications_delivered'] == 12
|
||||
assert result['data'][1]['notification_count'] == 77
|
||||
assert result['data'][1]['notifications_failed'] == 5
|
||||
assert result['data'][1]['notifications_requested'] == 40
|
||||
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):
|
||||
service_id = 'service_id'
|
||||
job_1_id = 'job_id_1'
|
||||
job_2_id = 'job_id_2'
|
||||
|
||||
expected_data = {'data': [{
|
||||
'original_file_name': 'email job.ods',
|
||||
'delivered': 1,
|
||||
'notification_count': 0,
|
||||
'sent': 20,
|
||||
'template_id': 'some_id',
|
||||
'template_version': 1,
|
||||
'notifications_failed': 0,
|
||||
'scheduled_for': None,
|
||||
'job_status': 'finished',
|
||||
'created_at': '2017-08-15T10:57:57.702936Z',
|
||||
'id': service_id,
|
||||
'job_id': job_1_id,
|
||||
'notifications_delivered': 1,
|
||||
'failed': 0,
|
||||
'service_id': service_id,
|
||||
'requested': 1},
|
||||
{'original_file_name': 'email job.ods',
|
||||
'delivered': 1,
|
||||
'notification_count': 1,
|
||||
'sent': 1,
|
||||
'template_id': 'some_id',
|
||||
'template_version': 1,
|
||||
'notifications_failed': 0,
|
||||
'scheduled_for': None,
|
||||
'job_status': 'finished',
|
||||
'created_at': '2017-08-15T10:17:06.731181Z',
|
||||
'id': service_id,
|
||||
'job_id': job_2_id,
|
||||
'notifications_delivered': 1,
|
||||
'failed': 0,
|
||||
'service_id': '66febfde-1df1-4524-9724-5b5856472f88',
|
||||
'requested': 1}],
|
||||
'links': {}, 'total': 4, 'page_size': 50}
|
||||
'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/job-stats'.format(service_id)
|
||||
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)
|
||||
@@ -271,12 +292,14 @@ def test_client_parses_empty_job_stats_for_service(mocker):
|
||||
|
||||
mock_get.assert_called_once_with(url=expected_url, params={'page': 1})
|
||||
assert result['data'][0]['id'] == job_1_id
|
||||
assert result['data'][0]['notifications_delivered'] == 1
|
||||
assert result['data'][0]['notification_count'] == 20
|
||||
assert result['data'][0]['notifications_requested'] == 0
|
||||
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_delivered'] == 1
|
||||
assert result['data'][1]['notification_count'] == 1
|
||||
assert result['data'][1]['notifications_requested'] == 0
|
||||
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