@@ -794,6 +794,50 @@ 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" ,
800+ netloc = "localhost" ,
801+ path = "/api/v4/projects/1/repository/commits/6b2257ea" ,
802+ method = "get" ,
803+ )
804+ def resp_get_commit (url , request ):
805+ headers = {"content-type" : "application/json" }
806+ content = """{
807+ "id": "6b2257eabcec3db1f59dafbd84935e3caea04235",
808+ "short_id": "6b2257ea",
809+ "title": "Initial commit"
810+ }"""
811+ content = content .encode ("utf-8" )
812+ return response (200 , content , headers , None , 5 , request )
813+
814+ @urlmatch (
815+ scheme = "http" ,
816+ netloc = "localhost" ,
817+ path = "/api/v4/projects/1/repository/commits/6b2257ea" ,
818+ method = "post" ,
819+ )
820+ def resp_revert_commit (url , request ):
821+ headers = {"content-type" : "application/json" }
822+ content = """{
823+ "id": "8b090c1b79a14f2bd9e8a738f717824ff53aebad",
824+ "short_id": "8b090c1b",
825+ "title":"Revert \\ "Initial commit\\ ""
826+ }"""
827+ content = content .encode ("utf-8" )
828+ return response (200 , content , headers , None , 5 , request )
829+
830+ with HTTMock (resp_get_commit ):
831+ project = self .gl .projects .get (1 , lazy = True )
832+ commit = project .commits .get ("6b2257ea" )
833+ self .assertEqual (commit .short_id , "6b2257ea" )
834+ self .assertEqual (commit .title , "Initial commit" )
835+
836+ with HTTMock (resp_revert_commit ):
837+ revert_commit = commit .revert (branch = "master" )
838+ self .assertEqual (revert_commit ["short_id" ], "8b090c1b" )
839+ self .assertEqual (revert_commit ["title" ], 'Revert "Initial commit"' )
840+
797841 def test_update_submodule (self ):
798842 @urlmatch (
799843 scheme = "http" , netloc = "localhost" , path = "/api/v4/projects/1$" , method = "get"
0 commit comments