@@ -717,6 +717,56 @@ def resp_mark_all_as_done(url, request):
717
717
with HTTMock (resp_mark_all_as_done ):
718
718
self .gl .todos .mark_all_as_done ()
719
719
720
+ def test_update_submodule (self ):
721
+ @urlmatch (
722
+ scheme = "http" , netloc = "localhost" , path = "/api/v4/projects/1$" , method = "get"
723
+ )
724
+ def resp_get_project (url , request ):
725
+ headers = {"content-type" : "application/json" }
726
+ content = '{"name": "name", "id": 1}' .encode ("utf-8" )
727
+ return response (200 , content , headers , None , 5 , request )
728
+
729
+ @urlmatch (
730
+ scheme = "http" ,
731
+ netloc = "localhost" ,
732
+ path = "/api/v4/projects/$1/repository/submodules/foo%2Fbar" ,
733
+ method = "post" ,
734
+ )
735
+ def resp_update_submodule (url , request ):
736
+ headers = {"content-type" : "application/json" }
737
+ content = """{
738
+ "id": "ed899a2f4b50b4370feeea94676502b42383c746",
739
+ "short_id": "ed899a2f4b5",
740
+ "title": "Message",
741
+ "author_name": "Author",
742
+ "author_email": "author@example.com",
743
+ "committer_name": "Author",
744
+ "committer_email": "author@example.com",
745
+ "created_at": "2018-09-20T09:26:24.000-07:00",
746
+ "message": "Message",
747
+ "parent_ids": [ "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba" ],
748
+ "committed_date": "2018-09-20T09:26:24.000-07:00",
749
+ "authored_date": "2018-09-20T09:26:24.000-07:00",
750
+ "status": null}"""
751
+ content = content .encode ("utf-8" )
752
+ return response (200 , content , headers , None , 5 , request )
753
+
754
+ with HTTMock (resp_update_submodule ):
755
+ project = self .gl .projects .get (1 )
756
+ self .assertIsInstance (project , Project )
757
+ self .assertEqual (project .name , "name" )
758
+ self .assertEqual (project .id , 1 )
759
+
760
+ ret = project .update_submodule (
761
+ submodule = "foo/bar" ,
762
+ branch = "master" ,
763
+ commit_sha = "4c3674f66071e30b3311dac9b9ccc90502a72664" ,
764
+ commit_message = "Message" ,
765
+ )
766
+ self .assertIsInstance (ret , dict )
767
+ self .assertEqual (ret ["message" ], "Message" )
768
+ self .assertEqual (ret ["id" ], "ed899a2f4b50b4370feeea94676502b42383c746" )
769
+
720
770
def _default_config (self ):
721
771
fd , temp_path = tempfile .mkstemp ()
722
772
os .write (fd , valid_config )
0 commit comments