@@ -212,3 +212,56 @@ def test_download_project_export(self):
212212 download = export .download ()
213213 self .assertIsInstance (download , bytes )
214214 self .assertEqual (download , binary_content )
215+
216+
217+ @urlmatch (
218+ scheme = "http" , netloc = "localhost" , path = "/api/v4/projects/import" , method = "post" ,
219+ )
220+ def resp_import_project (url , request ):
221+ """Mock for Project Import POST response"""
222+ content = """{
223+ "id": 1,
224+ "description": null,
225+ "name": "api-project",
226+ "name_with_namespace": "Administrator / api-project",
227+ "path": "api-project",
228+ "path_with_namespace": "root/api-project",
229+ "created_at": "2018-02-13T09:05:58.023Z",
230+ "import_status": "scheduled"
231+ }"""
232+ content = content .encode ("utf-8" )
233+ return response (200 , content , headers , None , 25 , request )
234+
235+
236+ @urlmatch (
237+ scheme = "http" , netloc = "localhost" , path = "/api/v4/projects/1/import" , method = "get" ,
238+ )
239+ def resp_import_status (url , request ):
240+ """Mock for Project Import GET response"""
241+ content = """{
242+ "id": 1,
243+ "description": "Itaque perspiciatis minima aspernatur corporis consequatur.",
244+ "name": "Gitlab Test",
245+ "name_with_namespace": "Gitlab Org / Gitlab Test",
246+ "path": "gitlab-test",
247+ "path_with_namespace": "gitlab-org/gitlab-test",
248+ "created_at": "2017-08-29T04:36:44.383Z",
249+ "import_status": "finished"
250+ }"""
251+ content = content .encode ("utf-8" )
252+ return response (200 , content , headers , None , 25 , request )
253+
254+
255+ class TestProjectImport (TestProject ):
256+ # import_github is tested in test_gitlab.py
257+
258+ @with_httmock (resp_import_project )
259+ def test_import_project (self ):
260+ project_import = self .gl .projects .import_project ("file" , "api-project" )
261+ self .assertEqual (project_import ["import_status" ], "scheduled" )
262+
263+ @with_httmock (resp_import_project , resp_import_status )
264+ def test_refresh_project_import_status (self ):
265+ project_import = self .project .imports .get ()
266+ project_import .refresh ()
267+ self .assertEqual (project_import .import_status , "finished" )
0 commit comments