Skip to content

Commit 696d7cf

Browse files
committed
Add constants for successful expected http status codes
1 parent 1e1c634 commit 696d7cf

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import pytest
1616

1717
import nucleus
18+
from nucleus.constants import SUCCESS_STATUS_CODES
1819

1920

2021
assert 'NUCLEUS_PYTEST_API_KEY' in os.environ, \
@@ -47,7 +48,7 @@ def _make_request_patch(
4748
payload: dict, route: str, requests_command=requests.post
4849
) -> dict:
4950
response = client._make_request_raw(payload, route, requests_command)
50-
assert response.status_code in [200, 201], \
51+
assert response.status_code in SUCCESS_STATUS_CODES, \
5152
f"HTTP response had status code: {response.status_code}. " \
5253
f"Full JSON: {response.json()}"
5354
return response.json()

nucleus/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
ANNOTATIONS_PROCESSED_KEY,
9797
PREDICTIONS_PROCESSED_KEY,
9898
STATUS_CODE_KEY,
99+
SUCCESS_STATUS_CODES,
99100
DATASET_NAME_KEY,
100101
DATASET_MODEL_RUNS_KEY,
101102
DATASET_SLICES_KEY,
@@ -917,7 +918,7 @@ def _make_request(
917918
"""
918919
response = self._make_request_raw(payload, route, requests_command)
919920

920-
if response.status_code not in [200, 201]:
921+
if response.status_code not in SUCCESS_STATUS_CODES:
921922
logger.warning(response)
922923

923924
return (

nucleus/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
ANNOTATIONS_PROCESSED_KEY = "annotations_processed"
1717
PREDICTIONS_PROCESSED_KEY = "predictions_processed"
1818
STATUS_CODE_KEY = "status_code"
19+
SUCCESS_STATUS_CODES = [200, 201]
1920
ERRORS_KEY = "errors"
2021
MODEL_RUN_ID_KEY = "model_run_id"
2122
MODEL_ID_KEY = "model_id"

0 commit comments

Comments
 (0)