Skip to content

Commit

Permalink
refactor: apply pr suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-canon committed Aug 2, 2023
1 parent 1e501f2 commit b8b3f65
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
10 changes: 8 additions & 2 deletions eox_nelp/api_clients/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
}
4 changes: 2 additions & 2 deletions eox_nelp/api_clients/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 response with status 400'})
requests_mock.Session.return_value.post.assert_called_with(
url=f"{api_client.base_url}/fake/path",
json=data,
Expand Down Expand Up @@ -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 response with status 404'})
requests_mock.Session.return_value.get.assert_called_with(
url=f"{api_client.base_url}/fake/path",
params=params,
Expand Down
4 changes: 2 additions & 2 deletions eox_nelp/api_clients/tests/tests_futurex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

0 comments on commit b8b3f65

Please sign in to comment.