Skip to content

Commit 9857393

Browse files
abhishekmsinghnejch
authored andcommitted
feat: fix func name, add func test, add docs
1 parent 2d5f341 commit 9857393

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

docs/gl_objects/projects.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,15 @@ Import the project into a namespace and override parameters::
342342
override_params={'visibility': 'private'},
343343
)
344344

345+
Import the project using file stored on a remote URL::
346+
347+
output = gl.projects.remote_import(
348+
url="https://whatever.com/url/file.tar.gz",
349+
path="my_new_remote_project",
350+
name="My New Remote Project",
351+
namespace="my-group",
352+
override_params={'visibility': 'private'},
353+
)
345354

346355
Project custom attributes
347356
=========================

gitlab/v4/objects/projects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ def import_project(
851851
"/projects/import", post_data=data, files=files, **kwargs
852852
)
853853

854-
def import_project_from_remote(
854+
def remote_import(
855855
self,
856856
url: str,
857857
path: str,

tests/functional/api/test_import_export.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import time
22

3+
import pytest
4+
35
import gitlab
46

57

@@ -64,3 +66,15 @@ def test_project_import_export(gl, project, temp_dir):
6466
count += 1
6567
if count == 15:
6668
raise Exception("Project import taking too much time")
69+
70+
71+
def test_project_remote_import(gl):
72+
with pytest.raises(gitlab.exceptions.GitlabHttpError) as err_info:
73+
gl.projects.remote_import(
74+
"ftp://whatever.com/url", "remote-project", "remote-project", "root"
75+
)
76+
assert err_info.value.response_code == 400
77+
assert (
78+
"File url is blocked: Only allowed schemes are https"
79+
in err_info.value.error_message
80+
)

tests/unit/objects/test_project_import_export.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def resp_import_project():
3030

3131

3232
@pytest.fixture
33-
def resp_import_project_from_remote():
33+
def resp_remote_import():
3434
content = {
3535
"id": 1,
3636
"description": None,
@@ -123,8 +123,8 @@ def test_import_project(gl, resp_import_project):
123123
assert project_import["import_status"] == "scheduled"
124124

125125

126-
def test_import_project_from_remote(gl, resp_import_project_from_remote):
127-
project_import = gl.projects.import_project_from_remote(
126+
def test_remote_import(gl, resp_remote_import):
127+
project_import = gl.projects.remote_import(
128128
"https://whatever.com/url", "remote-project", "remote-project", "root"
129129
)
130130
assert project_import["import_status"] == "scheduled"

0 commit comments

Comments
 (0)