summaryrefslogtreecommitdiff
path: root/gitlab/tests
diff options
context:
space:
mode:
authorNejc Habjan <hab.nejc@gmail.com>2020-03-08 18:37:34 +0100
committerNejc Habjan <nejc.habjan@siemens.com>2020-03-18 17:06:47 -0400
commitb8ea96cc20519b751631b27941d60c486aa4188c (patch)
tree2de3e9d4a1ccbccac1c2d77bc768e14ed482bc40 /gitlab/tests
parenta881fb71eebf744bcbe232869f622ea8a3ac975f (diff)
downloadgitlab-b8ea96cc20519b751631b27941d60c486aa4188c.tar.gz
chore: flatten test_import_github
Diffstat (limited to 'gitlab/tests')
-rw-r--r--gitlab/tests/objects/test_projects.py51
1 files changed, 26 insertions, 25 deletions
diff --git a/gitlab/tests/objects/test_projects.py b/gitlab/tests/objects/test_projects.py
index 93dadd0..1d72a72 100644
--- a/gitlab/tests/objects/test_projects.py
+++ b/gitlab/tests/objects/test_projects.py
@@ -252,6 +252,24 @@ def resp_import_status(url, request):
return response(200, content, headers, None, 25, request)
+@urlmatch(
+ scheme="http",
+ netloc="localhost",
+ path="/api/v4/import/github",
+ method="post",
+)
+def resp_import_github(url, request):
+ headers = {"content-type": "application/json"}
+ content = """{
+ "id": 27,
+ "name": "my-repo",
+ "full_path": "/root/my-repo",
+ "full_name": "Administrator / my-repo"
+ }"""
+ content = content.encode("utf-8")
+ return response(200, content, headers, None, 25, request)
+
+
class TestProjectImport(TestProject):
@with_httmock(resp_import_project)
def test_import_project(self):
@@ -264,29 +282,12 @@ class TestProjectImport(TestProject):
project_import.refresh()
self.assertEqual(project_import.import_status, "finished")
+ @with_httmock(resp_import_github)
def test_import_github(self):
- @urlmatch(
- scheme="http",
- netloc="localhost",
- path="/api/v4/import/github",
- method="post",
- )
- def resp_import_github(url, request):
- headers = {"content-type": "application/json"}
- content = """{
- "id": 27,
- "name": "my-repo",
- "full_path": "/root/my-repo",
- "full_name": "Administrator / my-repo"
- }"""
- content = content.encode("utf-8")
- return response(200, content, headers, None, 25, request)
-
- with HTTMock(resp_import_github):
- base_path = "/root"
- name = "my-repo"
- ret = self.gl.projects.import_github("githubkey", 1234, base_path, name)
- self.assertIsInstance(ret, dict)
- self.assertEqual(ret["name"], name)
- self.assertEqual(ret["full_path"], "/".join((base_path, name)))
- self.assertTrue(ret["full_name"].endswith(name))
+ base_path = "/root"
+ name = "my-repo"
+ ret = self.gl.projects.import_github("githubkey", 1234, base_path, name)
+ self.assertIsInstance(ret, dict)
+ self.assertEqual(ret["name"], name)
+ self.assertEqual(ret["full_path"], "/".join((base_path, name)))
+ self.assertTrue(ret["full_name"].endswith(name))