Skip to content

Commit 5d14867

Browse files
nejchJohnVillalovos
authored andcommitted
fix(cli): fix project export download for CLI
Since ac1c619 we delete parent arg keys from the args dict so this has been trying to access the wrong attribute.
1 parent 28cf3c3 commit 5d14867

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

gitlab/v4/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def do_custom(self) -> Any:
116116

117117
def do_project_export_download(self) -> None:
118118
try:
119-
project = self.gl.projects.get(int(self.args["project_id"]), lazy=True)
119+
project = self.gl.projects.get(self.parent_args["project_id"], lazy=True)
120120
export_status = project.exports.get()
121121
if TYPE_CHECKING:
122122
assert export_status is not None

tests/functional/cli/test_cli_projects.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import subprocess
2+
import time
3+
14
import pytest
25
import responses
36

@@ -25,3 +28,34 @@ def test_project_registry_delete_in_bulk(
2528
]
2629
ret = ret = script_runner.run(*cmd)
2730
assert ret.success
31+
32+
33+
@pytest.fixture
34+
def project_export(project):
35+
export = project.exports.create()
36+
export.refresh()
37+
38+
count = 0
39+
while export.export_status != "finished":
40+
time.sleep(0.5)
41+
export.refresh()
42+
count += 1
43+
if count == 30:
44+
raise Exception("Project export taking too much time")
45+
46+
return export
47+
48+
49+
def test_project_export_download(gitlab_config, project_export):
50+
cmd = [
51+
"gitlab",
52+
"--config-file",
53+
gitlab_config,
54+
"project-export",
55+
"download",
56+
"--project-id",
57+
str(project_export.id),
58+
]
59+
60+
export = subprocess.run(cmd, capture_output=True, check=True)
61+
assert export.returncode == 0

0 commit comments

Comments
 (0)