@@ -252,6 +252,24 @@ def resp_import_status(url, request):
252252 return response (200 , content , headers , None , 25 , request )
253253
254254
255+ @urlmatch (
256+ scheme = "http" ,
257+ netloc = "localhost" ,
258+ path = "/api/v4/import/github" ,
259+ method = "post" ,
260+ )
261+ def resp_import_github (url , request ):
262+ headers = {"content-type" : "application/json" }
263+ content = """{
264+ "id": 27,
265+ "name": "my-repo",
266+ "full_path": "/root/my-repo",
267+ "full_name": "Administrator / my-repo"
268+ }"""
269+ content = content .encode ("utf-8" )
270+ return response (200 , content , headers , None , 25 , request )
271+
272+
255273class TestProjectImport (TestProject ):
256274 @with_httmock (resp_import_project )
257275 def test_import_project (self ):
@@ -264,29 +282,12 @@ def test_refresh_project_import_status(self):
264282 project_import .refresh ()
265283 self .assertEqual (project_import .import_status , "finished" )
266284
285+ @with_httmock (resp_import_github )
267286 def test_import_github (self ):
268- @urlmatch (
269- scheme = "http" ,
270- netloc = "localhost" ,
271- path = "/api/v4/import/github" ,
272- method = "post" ,
273- )
274- def resp_import_github (url , request ):
275- headers = {"content-type" : "application/json" }
276- content = """{
277- "id": 27,
278- "name": "my-repo",
279- "full_path": "/root/my-repo",
280- "full_name": "Administrator / my-repo"
281- }"""
282- content = content .encode ("utf-8" )
283- return response (200 , content , headers , None , 25 , request )
284-
285- with HTTMock (resp_import_github ):
286- base_path = "/root"
287- name = "my-repo"
288- ret = self .gl .projects .import_github ("githubkey" , 1234 , base_path , name )
289- self .assertIsInstance (ret , dict )
290- self .assertEqual (ret ["name" ], name )
291- self .assertEqual (ret ["full_path" ], "/" .join ((base_path , name )))
292- self .assertTrue (ret ["full_name" ].endswith (name ))
287+ base_path = "/root"
288+ name = "my-repo"
289+ ret = self .gl .projects .import_github ("githubkey" , 1234 , base_path , name )
290+ self .assertIsInstance (ret , dict )
291+ self .assertEqual (ret ["name" ], name )
292+ self .assertEqual (ret ["full_path" ], "/" .join ((base_path , name )))
293+ self .assertTrue (ret ["full_name" ].endswith (name ))
0 commit comments