-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix APIErrorCode class (did not work as expected) (#191)
* Fix APIErrorCode class (did not work as expected) * Write tests * Update readme * Update supported python versions in setup.py
- Loading branch information
1 parent
be4bb51
commit 2996afb
Showing
4 changed files
with
59 additions
and
3 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
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from n2y.errors import APIErrorCode | ||
|
||
|
||
def test_apierrorcode_contains(): | ||
errors = [ | ||
("bad_gateway", True), | ||
("conflict_error", True), | ||
("database_connection_unavailable", True), | ||
("gateway_timeout", True), | ||
("internal_server_error", True), | ||
("invalid_grant", False), | ||
("invalid_json", False), | ||
("invalid_request", False), | ||
("invalid_request_url", False), | ||
("missing_version", False), | ||
("object_not_found", False), | ||
("rate_limited", True), | ||
("restricted_resource", False), | ||
("service_unavailable", True), | ||
("unauthorized", False), | ||
("validation_error", False), | ||
] | ||
for error, is_retryable in errors: | ||
assert error in APIErrorCode | ||
if is_retryable: | ||
assert ( | ||
error in APIErrorCode.RetryableCodes | ||
and error not in APIErrorCode.NonRetryableCodes | ||
) | ||
else: | ||
assert ( | ||
error in APIErrorCode.NonRetryableCodes | ||
and error not in APIErrorCode.RetryableCodes | ||
) | ||
assert APIErrorCode(error).is_retryable == is_retryable | ||
assert APIErrorCode(error).value == error |