Skip to content

Commit b1a883e

Browse files
authored
Merge pull request #28 from Rachaelisa/fix/19-implement-ratelimit-error
test(errors): add RateLimitError coverage (Closes #19)
2 parents f6a4cff + 85e8210 commit b1a883e

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/test_errors.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
InvalidRequestError,
55
NetworkError,
66
NotFoundError,
7+
RateLimitError,
78
ShadeError,
89
)
910

@@ -35,6 +36,7 @@ def test_specific_errors_inherit_from_shade_error():
3536
InvalidRequestError,
3637
NetworkError,
3738
NotFoundError,
39+
RateLimitError,
3840
):
3941
error = error_type("request failed", status_code=400, response_body="raw")
4042

@@ -43,12 +45,28 @@ def test_specific_errors_inherit_from_shade_error():
4345
assert error.response_body == "raw"
4446

4547

48+
def test_rate_limit_error_retry_after_from_header():
49+
error = RateLimitError("too many requests", retry_after=30)
50+
51+
assert isinstance(error, ShadeError)
52+
assert error.retry_after == 30
53+
assert error.status_code == 429
54+
55+
56+
def test_rate_limit_error_retry_after_none_when_absent():
57+
error = RateLimitError("too many requests")
58+
59+
assert error.retry_after is None
60+
assert error.status_code == 429
61+
62+
4663
def test_package_root_exports_error_classes():
4764
assert shade.ShadeError is ShadeError
4865
assert shade.AuthenticationError is AuthenticationError
4966
assert shade.InvalidRequestError is InvalidRequestError
5067
assert shade.NetworkError is NetworkError
5168
assert shade.NotFoundError is NotFoundError
69+
assert shade.RateLimitError is RateLimitError
5270

5371

5472
def test_not_found_error_is_shade_error():

0 commit comments

Comments
 (0)