Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd7a3066

Browse files
committed
test: add unit tests for revert commit API
1 parentb77b945 commitd7a3066

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

‎gitlab/tests/test_gitlab.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,58 @@ def resp_deactivate(url, request):
794794
self.gl.users.get(1,lazy=True).activate()
795795
self.gl.users.get(1,lazy=True).deactivate()
796796

797+
deftest_commit_revert(self):
798+
@urlmatch(
799+
scheme="http",netloc="localhost",path="/api/v4/projects/1$",method="get"
800+
)
801+
defresp_get_project(url,request):
802+
headers= {"content-type":"application/json"}
803+
content='{"name": "name", "id": 1}'.encode("utf-8")
804+
returnresponse(200,content,headers,None,5,request)
805+
806+
@urlmatch(
807+
scheme="http",
808+
netloc="localhost",
809+
path="/api/v4/projects/1/repository/commits/6b2257ea",
810+
method="get",
811+
)
812+
defresp_get_commit(url,request):
813+
headers= {"content-type":"application/json"}
814+
content="""{
815+
"id": "6b2257eabcec3db1f59dafbd84935e3caea04235",
816+
"short_id": "6b2257ea",
817+
"title": "Initial commit"
818+
}"""
819+
content=content.encode("utf-8")
820+
returnresponse(200,content,headers,None,5,request)
821+
822+
@urlmatch(
823+
scheme="http",
824+
netloc="localhost",
825+
path="/api/v4/projects/1/repository/commits/6b2257ea",
826+
method="post",
827+
)
828+
defresp_revert_commit(url,request):
829+
headers= {"content-type":"application/json"}
830+
content="""{
831+
"id": "8b090c1b79a14f2bd9e8a738f717824ff53aebad",
832+
"short_id": "8b090c1b",
833+
"title":"Revert\\"Initial commit\\""
834+
}"""
835+
content=content.encode("utf-8")
836+
returnresponse(200,content,headers,None,5,request)
837+
838+
withHTTMock(resp_get_project,resp_get_commit):
839+
project=self.gl.projects.get(1)
840+
commit=project.commits.get("6b2257ea")
841+
self.assertEqual(commit.short_id,"6b2257ea")
842+
self.assertEqual(commit.title,"Initial commit")
843+
844+
withHTTMock(resp_revert_commit):
845+
revert_commit=commit.revert(branch="master")
846+
self.assertEqual(revert_commit["short_id"],"8b090c1b")
847+
self.assertEqual(revert_commit["title"],'Revert "Initial commit"')
848+
797849
deftest_update_submodule(self):
798850
@urlmatch(
799851
scheme="http",netloc="localhost",path="/api/v4/projects/1$",method="get"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp