Skip to content

Commit d0cb40c

Browse files
committed
test(client): cover unknown status fallback
Exercise the defensive ValueError path used when the server returns a status code that is not part of http.HTTPStatus, so the fallback does not mask the original GitlabHttpError.
1 parent 14ed020 commit d0cb40c

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎tests/unit/test_gitlab_http_methods.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,25 @@ def test_head_request_error_without_body_uses_reason(gl):
550550
assert str(error) == "404: Not Found"
551551

552552

553+
@responses.activate
554+
def test_head_request_error_with_unknown_status_preserves_error(gl):
555+
url = "http://localhost/api/v4/not_there"
556+
responses.add(
557+
method=responses.HEAD,
558+
url=url,
559+
status=599,
560+
match=helpers.MATCH_EMPTY_QUERY_PARAMS,
561+
)
562+
563+
with pytest.raises(GitlabHttpError) as exc_info:
564+
gl.http_head("/not_there")
565+
566+
error = exc_info.value
567+
assert error.response_code == 599
568+
assert error.response_body == b""
569+
assert str(error).startswith("599:")
570+
571+
553572
@responses.activate
554573
def test_http_request_error_message_takes_precedence_over_reason(gl):
555574
url = "http://localhost/api/v4/not_there"

0 commit comments

Comments
 (0)