Skip to content

Commit 7a98fbe

Browse files
d-coleebyhr
authored andcommitted
Add test for error codes that are not retried
1 parent e81d9bc commit 7a98fbe

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/unit/test_client.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,30 @@ def test_5XX_error_retry(status_code, attempts, monkeypatch):
777777
assert post_retry.retry_count == attempts
778778

779779

780+
@pytest.mark.parametrize("status_code", [
781+
501
782+
])
783+
def test_error_no_retry(status_code, monkeypatch):
784+
http_resp = TrinoRequest.http.Response()
785+
http_resp.status_code = status_code
786+
787+
post_retry = RetryRecorder(result=http_resp)
788+
monkeypatch.setattr(TrinoRequest.http.Session, "post", post_retry)
789+
790+
get_retry = RetryRecorder(result=http_resp)
791+
monkeypatch.setattr(TrinoRequest.http.Session, "get", get_retry)
792+
793+
req = TrinoRequest(
794+
host="coordinator", port=8080, user="test", max_attempts=3
795+
)
796+
797+
req.post("URL")
798+
assert post_retry.retry_count == 1
799+
800+
req.get("URL")
801+
assert post_retry.retry_count == 1
802+
803+
780804
class FakeGatewayResponse(object):
781805
def __init__(self, http_response, redirect_count=1):
782806
self.__name__ = "FakeGatewayResponse"

0 commit comments

Comments
 (0)