Skip to content

Commit a881fb7

Browse files
committed
chore: move test_import_github into TestProjectImport
1 parent f7aad5f commit a881fb7

File tree

2 files changed

+27
-29
lines changed

2 files changed

+27
-29
lines changed

gitlab/tests/objects/test_projects.py

+27-2
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,6 @@ def resp_import_status(url, request):
253253

254254

255255
class TestProjectImport(TestProject):
256-
# import_github is tested in test_gitlab.py
257-
258256
@with_httmock(resp_import_project)
259257
def test_import_project(self):
260258
project_import = self.gl.projects.import_project("file", "api-project")
@@ -265,3 +263,30 @@ def test_refresh_project_import_status(self):
265263
project_import = self.project.imports.get()
266264
project_import.refresh()
267265
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))

gitlab/tests/test_gitlab.py

-27
Original file line numberDiff line numberDiff line change
@@ -937,33 +937,6 @@ def resp_update_submodule(url, request):
937937
self.assertEqual(ret["message"], "Message")
938938
self.assertEqual(ret["id"], "ed899a2f4b50b4370feeea94676502b42383c746")
939939

940-
def test_import_github(self):
941-
@urlmatch(
942-
scheme="http",
943-
netloc="localhost",
944-
path="/api/v4/import/github",
945-
method="post",
946-
)
947-
def resp_import_github(url, request):
948-
headers = {"content-type": "application/json"}
949-
content = """{
950-
"id": 27,
951-
"name": "my-repo",
952-
"full_path": "/root/my-repo",
953-
"full_name": "Administrator / my-repo"
954-
}"""
955-
content = content.encode("utf-8")
956-
return response(200, content, headers, None, 25, request)
957-
958-
with HTTMock(resp_import_github):
959-
base_path = "/root"
960-
name = "my-repo"
961-
ret = self.gl.projects.import_github("githubkey", 1234, base_path, name)
962-
self.assertIsInstance(ret, dict)
963-
self.assertEqual(ret["name"], name)
964-
self.assertEqual(ret["full_path"], "/".join((base_path, name)))
965-
self.assertTrue(ret["full_name"].endswith(name))
966-
967940
def test_applications(self):
968941
content = '{"name": "test_app", "redirect_uri": "http://localhost:8080", "scopes": ["api", "email"]}'
969942
json_content = json.loads(content)

0 commit comments

Comments
 (0)