From 55650070d55b71ea5a5e767d12c91893c24efa67 Mon Sep 17 00:00:00 2001 From: QFer <46991941+QFer@users.noreply.github.com> Date: Fri, 14 Jan 2022 09:09:45 +0100 Subject: [PATCH] [ISSUE-128] job delete (#130) --- src/quantuminspire/api.py | 8 ++------ src/tests/quantuminspire/test_api.py | 4 +--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/quantuminspire/api.py b/src/quantuminspire/api.py index 8048ef7..1a816f5 100644 --- a/src/quantuminspire/api.py +++ b/src/quantuminspire/api.py @@ -463,21 +463,17 @@ def get_jobs_from_project(self, project_id: int) -> List[Dict[str, Any]]: ret: List[Dict[str, Any]] = jobs return ret - def delete_job(self, job_id: int) -> Dict[str, Any]: + def delete_job(self, job_id: int) -> None: """ Deletes the job identified by `job_id`. Only jobs can be deleted that are registered for the user the API is currently authenticated for. :param job_id: The job identification number. - :return: - The deleted job indicated by the job identification number. - See :meth:`~.get_job` for a description of the job properties. - :raises ApiError: If the job identified by `job_id` does not exist. """ try: - return dict(self._action(['jobs', 'delete'], params={'id': job_id})) + self._action(['jobs', 'delete'], params={'id': job_id}) except ErrorMessage as err_msg: raise ApiError(f'Job with id {job_id} does not exist!') from err_msg diff --git a/src/tests/quantuminspire/test_api.py b/src/tests/quantuminspire/test_api.py index 194f209..32d3f25 100644 --- a/src/tests/quantuminspire/test_api.py +++ b/src/tests/quantuminspire/test_api.py @@ -475,11 +475,9 @@ def test_get_jobs_from_asset_raises_api_error(self): def test_delete_job_has_correct_in_and_output(self): identity = 509 expected_payload = {'id': identity} - expected = self.__mock_job_handler(expected_payload, 'delete', None, None, ['test', 'delete'], expected_payload) self.coreapi_client.handlers['jobs'] = partial(self.__mock_job_handler, expected_payload, 'delete') api = QuantumInspireAPI('FakeURL', self.authentication, coreapi_client_class=self.coreapi_client) - actual = api.delete_job(job_id=identity) - self.assertEqual(actual, expected) + self.assertIsNone(api.delete_job(job_id=identity)) def test_delete_job_raises_api_error(self): identity = 999