def get_object(self): try: status = get_job_status(self.request.user, self.kwargs['job_id']) except PermissionDenied: self.add_tracking_data(missing_permissions=[perms.JOB_GLOBAL_READ]) raise except ObjectDoesNotExist as ex: self.add_tracking_data(failure='job_not_found') raise Http404() from ex self.add_tracking_data(job_state=status.state) return status
def assert_succeeded(self, expected_contents, expected_text, job_id=None): """ Assert that the task identified by `job_id` succeeded and that its contents are equal to `expected_contents`. If `job_id` is None, use `self.job_id`. """ status = get_job_status(self.user, job_id or self.job_id) self.assertEqual(status.state, UserTaskStatus.SUCCEEDED) self.assertEqual(status.text, expected_text) result_response = requests.get(status.result) self.assertIn(result_response.text, expected_contents)