mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Don’t assume jobs status will be present
The API response for jobs includes a field called `job_status`. The API response for uploads doesn’t. The `Job` mode handles uploads and jobs, so it needs to account for the possibility of the field not being there.
This commit is contained in:
@@ -34,7 +34,7 @@ class Job(JSONModel):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def status(self):
|
def status(self):
|
||||||
return self.job_status
|
return self._dict.get('job_status')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def cancelled(self):
|
def cancelled(self):
|
||||||
|
|||||||
@@ -1732,14 +1732,12 @@ def mock_get_uploads(mocker, api_user_active):
|
|||||||
'notification_count': 10,
|
'notification_count': 10,
|
||||||
'created_at': '2016-01-01 11:09:00.061258',
|
'created_at': '2016-01-01 11:09:00.061258',
|
||||||
'statistics': [{'count': 8, 'status': 'delivered'}, {'count': 2, 'status': 'temporary-failure'}],
|
'statistics': [{'count': 8, 'status': 'delivered'}, {'count': 2, 'status': 'temporary-failure'}],
|
||||||
'job_status': 'finished',
|
|
||||||
'upload_type': 'job'},
|
'upload_type': 'job'},
|
||||||
{'id': 'job_id_1',
|
{'id': 'job_id_1',
|
||||||
'original_file_name': 'some.csv',
|
'original_file_name': 'some.csv',
|
||||||
'notification_count': 1,
|
'notification_count': 1,
|
||||||
'created_at': '2016-01-01 11:09:00.061258',
|
'created_at': '2016-01-01 11:09:00.061258',
|
||||||
'statistics': [{'count': 1, 'status': 'delivered'}],
|
'statistics': [{'count': 1, 'status': 'delivered'}],
|
||||||
'job_status': 'finished',
|
|
||||||
'upload_type': 'letter'}
|
'upload_type': 'letter'}
|
||||||
]
|
]
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user