Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf7aad5f

Browse files
committed
test: add unit tests for Project Import
1 parent600dc86 commitf7aad5f

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

‎gitlab/tests/objects/test_projects.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
defresp_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+
returnresponse(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+
defresp_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+
returnresponse(200,content,headers,None,25,request)
253+
254+
255+
classTestProjectImport(TestProject):
256+
# import_github is tested in test_gitlab.py
257+
258+
@with_httmock(resp_import_project)
259+
deftest_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+
deftest_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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp