summaryrefslogtreecommitdiff
path: root/tests/unit/test_gitlab_http_methods.py
diff options
context:
space:
mode:
authorJohn Villalovos <john@sodarock.com>2023-02-05 13:10:55 -0800
committerGitHub <noreply@github.com>2023-02-05 22:10:55 +0100
commitf711d9e2bf78f58cee6a7c5893d4acfd2f980397 (patch)
treef3e693cecb8526f09c3eec65a53b3bf0b513672c /tests/unit/test_gitlab_http_methods.py
parent08675643e6b306d3ae101b173609a6c363c9f3df (diff)
downloadgitlab-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.py50
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(