Skip to content

Commit

Permalink
Merge pull request #1047 from facebookresearch/add-prolific-unittests-2
Browse files Browse the repository at this point in the history
Add unittests for Prolific integration (2)
  • Loading branch information
JackUrb committed Aug 16, 2023
2 parents fb909e7 + 1a0d0d4 commit a5a90f2
Show file tree
Hide file tree
Showing 7 changed files with 1,025 additions and 79 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
2 changes: 2 additions & 0 deletions mephisto/abstractions/providers/prolific/prolific_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,8 @@ def add_workers_to_qualification(
)
raise

return None


def give_worker_qualification(
client: ProlificClient,
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 a5a90f2

Please sign in to comment.