diff options
| author | Abhishek Singh <abhiandthetruth@gmail.com> | 2022-11-02 13:59:06 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-02 09:29:06 +0100 |
| commit | 892281e35e3d81c9e43ff6a974f920daa83ea8b2 (patch) | |
| tree | 773a66ebeec30e993a2c81852de12a3ad4deac12 /tests | |
| parent | e5dc72de9b3cdf0a7944ee0961fbdc6784c7f315 (diff) | |
| download | gitlab-892281e35e3d81c9e43ff6a974f920daa83ea8b2.tar.gz | |
feat(api): add support for remote project import from AWS S3 (#2357)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/functional/api/test_import_export.py | 22 | ||||
| -rw-r--r-- | tests/unit/objects/test_project_import_export.py | 43 |
2 files changed, 63 insertions, 2 deletions
diff --git a/tests/functional/api/test_import_export.py b/tests/functional/api/test_import_export.py index 83cccc6..8f9db9c 100644 --- a/tests/functional/api/test_import_export.py +++ b/tests/functional/api/test_import_export.py @@ -69,7 +69,7 @@ def test_project_import_export(gl, project, temp_dir): def test_project_remote_import(gl): - with pytest.raises(gitlab.exceptions.GitlabHttpError) as err_info: + with pytest.raises(gitlab.exceptions.GitlabImportError) as err_info: gl.projects.remote_import( "ftp://whatever.com/url", "remote-project", "remote-project", "root" ) @@ -78,3 +78,23 @@ def test_project_remote_import(gl): "File url is blocked: Only allowed schemes are https" in err_info.value.error_message ) + + +def test_project_remote_import_s3(gl): + gl.features.set("import_project_from_remote_file_s3", True) + with pytest.raises(gitlab.exceptions.GitlabImportError) as err_info: + gl.projects.remote_import_s3( + "remote-project", + "aws-region", + "aws-bucket-name", + "aws-file-key", + "aws-access-key-id", + "secret-access-key", + "remote-project", + "root", + ) + assert err_info.value.response_code == 400 + assert ( + "Failed to open 'aws-file-key' in 'aws-bucket-name'" + in err_info.value.error_message + ) diff --git a/tests/unit/objects/test_project_import_export.py b/tests/unit/objects/test_project_import_export.py index 72321ec..bfe976f 100644 --- a/tests/unit/objects/test_project_import_export.py +++ b/tests/unit/objects/test_project_import_export.py @@ -54,6 +54,30 @@ def resp_remote_import(): @pytest.fixture +def resp_remote_import_s3(): + content = { + "id": 1, + "description": None, + "name": "remote-project-s3", + "name_with_namespace": "Administrator / remote-project-s3", + "path": "remote-project-s3", + "path_with_namespace": "root/remote-project-s3", + "created_at": "2018-02-13T09:05:58.023Z", + "import_status": "scheduled", + } + + with responses.RequestsMock() as rsps: + rsps.add( + method=responses.POST, + url="http://localhost/api/v4/projects/remote-import-s3", + json=content, + content_type="application/json", + status=200, + ) + yield rsps + + +@pytest.fixture def resp_import_status(): content = { "id": 1, @@ -125,7 +149,24 @@ def test_import_project(gl, resp_import_project): def test_remote_import(gl, resp_remote_import): project_import = gl.projects.remote_import( - "https://whatever.com/url", "remote-project", "remote-project", "root" + "https://whatever.com/url/file.tar.gz", + "remote-project", + "remote-project", + "root", + ) + assert project_import["import_status"] == "scheduled" + + +def test_remote_import_s3(gl, resp_remote_import_s3): + project_import = gl.projects.remote_import_s3( + "remote-project", + "aws-region", + "aws-bucket-name", + "aws-file-key", + "aws-access-key-id", + "secret-access-key", + "remote-project", + "root", ) assert project_import["import_status"] == "scheduled" |
