diff options
author | John Villalovos <john@sodarock.com> | 2023-02-05 13:10:55 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-05 22:10:55 +0100 |
commit | f711d9e2bf78f58cee6a7c5893d4acfd2f980397 (patch) | |
tree | f3e693cecb8526f09c3eec65a53b3bf0b513672c /tests/unit/test_gitlab_http_methods.py | |
parent | 08675643e6b306d3ae101b173609a6c363c9f3df (diff) | |
download | gitlab-f711d9e2bf78f58cee6a7c5893d4acfd2f980397.tar.gz |
feat(client): add http_patch method (#2471)
In order to support some new API calls we need to support the HTTP `PATCH` method.
Closes: #2469
Diffstat (limited to 'tests/unit/test_gitlab_http_methods.py')
-rw-r--r-- | tests/unit/test_gitlab_http_methods.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/unit/test_gitlab_http_methods.py b/tests/unit/test_gitlab_http_methods.py index 569df81..d7e375a 100644 --- a/tests/unit/test_gitlab_http_methods.py +++ b/tests/unit/test_gitlab_http_methods.py @@ -810,6 +810,56 @@ def test_put_request_invalid_data(gl): @responses.activate +def test_patch_request(gl): + url = "http://localhost/api/v4/projects" + responses.add( + method=responses.PATCH, + url=url, + json={"name": "project1"}, + status=200, + match=helpers.MATCH_EMPTY_QUERY_PARAMS, + ) + + result = gl.http_patch("/projects") + assert isinstance(result, dict) + assert result["name"] == "project1" + assert responses.assert_call_count(url, 1) is True + + +@responses.activate +def test_patch_request_404(gl): + url = "http://localhost/api/v4/not_there" + responses.add( + method=responses.PATCH, + url=url, + json=[], + status=404, + match=helpers.MATCH_EMPTY_QUERY_PARAMS, + ) + + with pytest.raises(GitlabHttpError): + gl.http_patch("/not_there") + assert responses.assert_call_count(url, 1) is True + + +@responses.activate +def test_patch_request_invalid_data(gl): + url = "http://localhost/api/v4/projects" + responses.add( + method=responses.PATCH, + url=url, + body='["name": "project1"]', + content_type="application/json", + status=200, + match=helpers.MATCH_EMPTY_QUERY_PARAMS, + ) + + with pytest.raises(GitlabParsingError): + gl.http_patch("/projects") + assert responses.assert_call_count(url, 1) is True + + +@responses.activate def test_delete_request(gl): url = "http://localhost/api/v4/projects" responses.add( |