-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor HTTP status codes for external resources (#2199)
* Refactor HTTP status codes for external resources * Refactor hard-coded values in unit test * Refactor hard-coded status codes in api test
- Loading branch information
Showing
3 changed files
with
69 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
"""Constants for External Resources module""" | ||
|
||
# HTTP Status Codes | ||
HTTP_BAD_REQUEST = 400 | ||
HTTP_UNAUTHORIZED = 401 | ||
HTTP_PAYMENT_REQUIRED = 402 | ||
HTTP_FORBIDDEN = 403 | ||
HTTP_TOO_MANY_REQUESTS = 429 | ||
HTTP_REQUEST_TIMEOUT = 408 | ||
HTTP_SERVICE_UNAVAILABLE = 503 | ||
from rest_framework.status import ( | ||
HTTP_400_BAD_REQUEST, | ||
HTTP_401_UNAUTHORIZED, | ||
HTTP_402_PAYMENT_REQUIRED, | ||
HTTP_403_FORBIDDEN, | ||
HTTP_408_REQUEST_TIMEOUT, | ||
HTTP_429_TOO_MANY_REQUESTS, | ||
HTTP_503_SERVICE_UNAVAILABLE, | ||
) | ||
|
||
# External Resource | ||
RESOURCE_BROKEN_STATUS_START = HTTP_BAD_REQUEST | ||
# constants for external resources | ||
RESOURCE_BROKEN_STATUS_START = HTTP_400_BAD_REQUEST | ||
RESOURCE_BROKEN_STATUS_END = 600 | ||
RESOURCE_UNCHECKED_STATUSES = [ | ||
HTTP_UNAUTHORIZED, | ||
HTTP_PAYMENT_REQUIRED, | ||
HTTP_FORBIDDEN, | ||
HTTP_TOO_MANY_REQUESTS, | ||
HTTP_REQUEST_TIMEOUT, | ||
HTTP_SERVICE_UNAVAILABLE, | ||
HTTP_401_UNAUTHORIZED, | ||
HTTP_402_PAYMENT_REQUIRED, | ||
HTTP_403_FORBIDDEN, | ||
HTTP_408_REQUEST_TIMEOUT, | ||
HTTP_429_TOO_MANY_REQUESTS, | ||
HTTP_503_SERVICE_UNAVAILABLE, | ||
] | ||
|
||
# Celery Task | ||
# constants for Celery task | ||
EXTERNAL_RESOURCE_TASK_RATE_LIMIT = "100/s" | ||
EXTERNAL_RESOURCE_TASK_PRIORITY = 4 # Lowest priority from range (0 - 4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters