8000 fix(client): handle empty 204 reponses in PUT requests · python-gitlab/python-gitlab@3cda8ee · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 3cda8ee

Browse files
committed
fix(client): handle empty 204 reponses in PUT requests
1 parent 70959e8 commit 3cda8ee

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

gitlab/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,8 @@ def http_put(
10611061
raw=raw,
10621062
**kwargs,
10631063
)
1064+
if result.status_code in gitlab.const.NO_JSON_RESPONSE_CODES:
1065+
return result
10641066
try:
10651067
json_result = result.json()
10661068
if TYPE_CHECKING:

tests/unit/test_gitlab_http_methods.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,21 @@ def test_put_request_404(gl):
766766
assert responses.assert_call_count(url, 1) is True
767767

768768

769+
@responses.activate
770+
def test_patch_request_204(gl):
771+
url = "http://localhost/api/v4/projects"
772+
responses.add(
773+
method=responses.PUT,
774+
url=url,
775+
status=204,
776+
match=helpers.MATCH_EMPTY_QUERY_PARAMS,
777+
)
778+
779+
result = gl.http_put("/projects")
780+
assert isinstance(result, requests.Response)
781+
assert responses.assert_call_count(url, 1) is True
782+
783+
769784
@responses.activate
770785
def test_put_request_invalid_data(gl):
771786
url = "http://localhost/api/v4/projects"

0 commit comments

Comments
 (0)
0