diff options
author | Nejc Habjan <hab.nejc@gmail.com> | 2020-03-08 18:33:07 +0100 |
---|---|---|
committer | Nejc Habjan <nejc.habjan@siemens.com> | 2020-03-18 17:06:47 -0400 |
commit | a881fb71eebf744bcbe232869f622ea8a3ac975f (patch) | |
tree | fa43a97ebb9b6f2b7c870a9864fc4ba3e73ccc93 /gitlab | |
parent | f7aad5f78c49ad1a4e05a393bcf236b7bbad2f2a (diff) | |
download | gitlab-a881fb71eebf744bcbe232869f622ea8a3ac975f.tar.gz |
chore: move test_import_github into TestProjectImport
Diffstat (limited to 'gitlab')
-rw-r--r-- | gitlab/tests/objects/test_projects.py | 29 | ||||
-rw-r--r-- | gitlab/tests/test_gitlab.py | 27 |
2 files changed, 27 insertions, 29 deletions
diff --git a/gitlab/tests/objects/test_projects.py b/gitlab/tests/objects/test_projects.py index 010ce04..93dadd0 100644 --- a/gitlab/tests/objects/test_projects.py +++ b/gitlab/tests/objects/test_projects.py @@ -253,8 +253,6 @@ def resp_import_status(url, request): class TestProjectImport(TestProject): - # import_github is tested in test_gitlab.py - @with_httmock(resp_import_project) def test_import_project(self): project_import = self.gl.projects.import_project("file", "api-project") @@ -265,3 +263,30 @@ class TestProjectImport(TestProject): project_import = self.project.imports.get() project_import.refresh() self.assertEqual(project_import.import_status, "finished") + + 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)) diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py index 249d0c5..591f166 100644 --- a/gitlab/tests/test_gitlab.py +++ b/gitlab/tests/test_gitlab.py @@ -937,33 +937,6 @@ class TestGitlab(unittest.TestCase): self.assertEqual(ret["message"], "Message") self.assertEqual(ret["id"], "ed899a2f4b50b4370feeea94676502b42383c746") - 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)) - def test_applications(self): content = '{"name": "test_app", "redirect_uri": "http://localhost:8080", "scopes": ["api", "email"]}' json_content = json.loads(content) |