diff options
author | Nejc Habjan <nejc.habjan@siemens.com> | 2022-05-31 22:25:59 +0200 |
---|---|---|
committer | John Villalovos <john@sodarock.com> | 2022-06-01 08:00:51 -0700 |
commit | 5d1486785793b02038ac6f527219801744ee888b (patch) | |
tree | 26a92a1a9ab4d604bb67d1d67db017d8d4b0f34e | |
parent | 28cf3c3d392f2f7f55dc142681181e15c702018a (diff) | |
download | gitlab-5d1486785793b02038ac6f527219801744ee888b.tar.gz |
fix(cli): fix project export download for CLI
Since ac1c619cae6481833f5df91862624bf0380fef67 we delete parent arg keys
from the args dict so this has been trying to access the wrong attribute.
-rw-r--r-- | gitlab/v4/cli.py | 2 | ||||
-rw-r--r-- | tests/functional/cli/test_cli_projects.py | 34 |
2 files changed, 35 insertions, 1 deletions
diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py index 98430b9..bd6a6a4 100644 --- a/gitlab/v4/cli.py +++ b/gitlab/v4/cli.py @@ -116,7 +116,7 @@ class GitlabCLI: def do_project_export_download(self) -> None: try: - project = self.gl.projects.get(int(self.args["project_id"]), lazy=True) + project = self.gl.projects.get(self.parent_args["project_id"], lazy=True) export_status = project.exports.get() if TYPE_CHECKING: assert export_status is not None diff --git a/tests/functional/cli/test_cli_projects.py b/tests/functional/cli/test_cli_projects.py index bf7f564..c514af4 100644 --- a/tests/functional/cli/test_cli_projects.py +++ b/tests/functional/cli/test_cli_projects.py @@ -1,3 +1,6 @@ +import subprocess +import time + import pytest import responses @@ -25,3 +28,34 @@ def test_project_registry_delete_in_bulk( ] ret = ret = script_runner.run(*cmd) assert ret.success + + +@pytest.fixture +def project_export(project): + export = project.exports.create() + export.refresh() + + count = 0 + while export.export_status != "finished": + time.sleep(0.5) + export.refresh() + count += 1 + if count == 30: + raise Exception("Project export taking too much time") + + return export + + +def test_project_export_download(gitlab_config, project_export): + cmd = [ + "gitlab", + "--config-file", + gitlab_config, + "project-export", + "download", + "--project-id", + str(project_export.id), + ] + + export = subprocess.run(cmd, capture_output=True, check=True) + assert export.returncode == 0 |