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:
Chris Hill-Scott
2020-01-20 15:25:47 +00:00
parent 182c47dfa6
commit 32105b3328
2 changed files with 1 additions and 3 deletions

View File

@@ -34,7 +34,7 @@ class Job(JSONModel):
@property
def status(self):
return self.job_status
return self._dict.get('job_status')
@property
def cancelled(self):

View File

@@ -1732,14 +1732,12 @@ def mock_get_uploads(mocker, api_user_active):
'notification_count': 10,
'created_at': '2016-01-01 11:09:00.061258',
'statistics': [{'count': 8, 'status': 'delivered'}, {'count': 2, 'status': 'temporary-failure'}],
'job_status': 'finished',
'upload_type': 'job'},
{'id': 'job_id_1',
'original_file_name': 'some.csv',
'notification_count': 1,
'created_at': '2016-01-01 11:09:00.061258',
'statistics': [{'count': 1, 'status': 'delivered'}],
'job_status': 'finished',
'upload_type': 'letter'}
]
return {