summaryrefslogtreecommitdiff
path: root/gitlab/tests/test_gitlab.py
diff options
context:
space:
mode:
authorMax Wittig <max.wittig@siemens.com>2020-02-20 09:06:23 +0100
committerGitHub <noreply@github.com>2020-02-20 09:06:23 +0100
commite8f0921d164c4b7db78e2f62e75eb32094b4456e (patch)
treed603f98235d9bfb6b1968a4e3412bb0d8efe72ba /gitlab/tests/test_gitlab.py
parent19242c398b9074e04e35cc687c31c543a10db280 (diff)
parentcb436951b1fde9c010e966819c75d0d7adacf17d (diff)
downloadgitlab-e8f0921d164c4b7db78e2f62e75eb32094b4456e.tar.gz
Merge pull request #1020 from nejch/feat/revert-commit-api
feat: add support for commit revert API (#991)
Diffstat (limited to 'gitlab/tests/test_gitlab.py')
-rw-r--r--gitlab/tests/test_gitlab.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py
index 3eccf6e..b56889a 100644
--- a/gitlab/tests/test_gitlab.py
+++ b/gitlab/tests/test_gitlab.py
@@ -794,6 +794,50 @@ class TestGitlab(unittest.TestCase):
self.gl.users.get(1, lazy=True).activate()
self.gl.users.get(1, lazy=True).deactivate()
+ def test_commit_revert(self):
+ @urlmatch(
+ scheme="http",
+ netloc="localhost",
+ path="/api/v4/projects/1/repository/commits/6b2257ea",
+ method="get",
+ )
+ def resp_get_commit(url, request):
+ headers = {"content-type": "application/json"}
+ content = """{
+ "id": "6b2257eabcec3db1f59dafbd84935e3caea04235",
+ "short_id": "6b2257ea",
+ "title": "Initial commit"
+ }"""
+ content = content.encode("utf-8")
+ return response(200, content, headers, None, 5, request)
+
+ @urlmatch(
+ scheme="http",
+ netloc="localhost",
+ path="/api/v4/projects/1/repository/commits/6b2257ea",
+ method="post",
+ )
+ def resp_revert_commit(url, request):
+ headers = {"content-type": "application/json"}
+ content = """{
+ "id": "8b090c1b79a14f2bd9e8a738f717824ff53aebad",
+ "short_id": "8b090c1b",
+ "title":"Revert \\"Initial commit\\""
+ }"""
+ content = content.encode("utf-8")
+ return response(200, content, headers, None, 5, request)
+
+ with HTTMock(resp_get_commit):
+ project = self.gl.projects.get(1, lazy=True)
+ commit = project.commits.get("6b2257ea")
+ self.assertEqual(commit.short_id, "6b2257ea")
+ self.assertEqual(commit.title, "Initial commit")
+
+ with HTTMock(resp_revert_commit):
+ revert_commit = commit.revert(branch="master")
+ self.assertEqual(revert_commit["short_id"], "8b090c1b")
+ self.assertEqual(revert_commit["title"], 'Revert "Initial commit"')
+
def test_update_submodule(self):
@urlmatch(
scheme="http", netloc="localhost", path="/api/v4/projects/1$", method="get"