diff --git a/eox_nelp/api_clients/__init__.py b/eox_nelp/api_clients/__init__.py index e845964a..637263f1 100644 --- a/eox_nelp/api_clients/__init__.py +++ b/eox_nelp/api_clients/__init__.py @@ -93,7 +93,10 @@ def make_post(self, path, data): response.status_code, ) - return {} + return { + "error": True, + "message": f"Invalid response with status {response.status_code}" + } def make_get(self, path, payload): """This method uses the session attribute to perform a GET request based on the @@ -120,4 +123,7 @@ def make_get(self, path, payload): response.status_code, ) - return {} + return { + "error": True, + "message": f"Invalid response with status {response.status_code}" + } diff --git a/eox_nelp/api_clients/tests/__init__.py b/eox_nelp/api_clients/tests/__init__.py index 2ee3ef21..8cb11cd7 100644 --- a/eox_nelp/api_clients/tests/__init__.py +++ b/eox_nelp/api_clients/tests/__init__.py @@ -108,7 +108,7 @@ def test_failed_post(self, auth_mock, requests_mock): with self.assertLogs(api_clients.__name__, level="ERROR") as logs: response = api_client.make_post("fake/path", data) - self.assertDictEqual(response, {}) + self.assertDictEqual(response, {'error': True, 'message': 'Invalid request with status 400'}) requests_mock.Session.return_value.post.assert_called_with( url=f"{api_client.base_url}/fake/path", json=data, @@ -169,7 +169,7 @@ def test_failed_get(self, auth_mock, requests_mock): with self.assertLogs(api_clients.__name__, level="ERROR") as logs: response = api_client.make_get("fake/path", params) - self.assertDictEqual(response, {}) + self.assertDictEqual(response, {'error': True, 'message': 'Invalid request with status 404'}) requests_mock.Session.return_value.get.assert_called_with( url=f"{api_client.base_url}/fake/path", params=params, diff --git a/eox_nelp/api_clients/tests/tests_futurex.py b/eox_nelp/api_clients/tests/tests_futurex.py index a9104ca3..01276806 100644 --- a/eox_nelp/api_clients/tests/tests_futurex.py +++ b/eox_nelp/api_clients/tests/tests_futurex.py @@ -41,7 +41,7 @@ def test_enrollment_progress(self, auth_mock, post_mock): "enrolledAt": "2012-12-30", "isCompleted": False, } - api_client = FuturexApiClient() + api_client = self.api_class() response = api_client.enrollment_progress(data) @@ -61,6 +61,6 @@ def test_failed_enrollment_progress(self, auth_mock): "userId": 52, "approxTotalCourseHrs": 5, } - api_client = FuturexApiClient() + api_client = self.api_class() self.assertRaises(FuturexMissingArguments, api_client.enrollment_progress, data)