@@ -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+ def test_commit_revert (self ):
798+ @urlmatch (
799+ scheme = "http" , netloc = "localhost" , path = "/api/v4/projects/1$" , method = "get"
800+ )
801+ def resp_get_project (url , request ):
802+ headers = {"content-type" : "application/json" }
803+ content = '{"name": "name", "id": 1}' .encode ("utf-8" )
804+ return response (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+ def resp_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+ return response (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+ def resp_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+ return response (200 , content , headers , None , 5 , request )
837+
838+ with HTTMock (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+ with HTTMock (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 def test_update_submodule (self ):
798850 @urlmatch (
799851 scheme = "http" , netloc = "localhost" , path = "/api/v4/projects/1$" , method = "get"
0 commit comments