Skip to content

Commit

Permalink
Added unittests for prolific_utils and base_api_resource
Browse files Browse the repository at this point in the history
  • Loading branch information
meta-paul committed Aug 16, 2023
1 parent d17d4bc commit 1a0d0d4
Show file tree
Hide file tree
Showing 6 changed files with 638 additions and 295 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def _base_request(

elif method == HTTPMethod.DELETE:
response = requests.delete(url, headers=headers, json=params)

else:
raise ProlificException("Invalid HTTP method.")

Expand All @@ -102,6 +103,10 @@ def _base_request(

return result

except ProlificException:
# Reraise these errors further to avoid catching them in the latest `except` condition
raise

except requests.exceptions.HTTPError as err:
logger.error(f"{log_prefix} Request error: {err}. Response text: `{err.response.text}`")
if err.response.status_code == status.HTTP_401_UNAUTHORIZED:
Expand Down
1 change: 1 addition & 0 deletions mephisto/abstractions/providers/prolific/api/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# LICENSE file in the root directory of this source tree.

# 2xx
HTTP_200_OK = 200
HTTP_204_NO_CONTENT = 204

# 4xx
Expand Down
5 changes: 5 additions & 0 deletions test/abstractions/providers/prolific/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env python3

# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
5 changes: 5 additions & 0 deletions test/abstractions/providers/prolific/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env python3

# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
Loading

0 comments on commit 1a0d0d4

Please sign in to comment.