@@ -253,8 +253,6 @@ def resp_import_status(url, request):
253
253
254
254
255
255
class TestProjectImport (TestProject ):
256
- # import_github is tested in test_gitlab.py
257
-
258
256
@with_httmock (resp_import_project )
259
257
def test_import_project (self ):
260
258
project_import = self .gl .projects .import_project ("file" , "api-project" )
@@ -265,3 +263,30 @@ def test_refresh_project_import_status(self):
265
263
project_import = self .project .imports .get ()
266
264
project_import .refresh ()
267
265
self .assertEqual (project_import .import_status , "finished" )
266
+
267
+ 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 ))
0 commit comments