From 32105b3328191ab8f1f38fd4da4e6c6a6263f948 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 20 Jan 2020 15:25:47 +0000 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20assume=20jobs=20status=20will?= =?UTF-8?q?=20be=20present?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- app/models/job.py | 2 +- tests/conftest.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/models/job.py b/app/models/job.py index a0af3ed3d..46498993f 100644 --- a/app/models/job.py +++ b/app/models/job.py @@ -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): diff --git a/tests/conftest.py b/tests/conftest.py index 7140bc66c..9ec007091 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 {