Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1202 from python-gitlab/fix/cli-binary-data
fix(cli): write binary data to stdout buffer
- Loading branch information
Showing
5 changed files
with
107 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import subprocess | ||
import sys | ||
import textwrap | ||
import time | ||
from io import BytesIO | ||
from zipfile import is_zipfile | ||
|
||
import pytest | ||
|
||
|
||
content = textwrap.dedent( | ||
"""\ | ||
test-artifact: | ||
script: echo "test" > artifact.txt | ||
artifacts: | ||
untracked: true | ||
""" | ||
) | ||
data = { | ||
"file_path": ".gitlab-ci.yml", | ||
"branch": "master", | ||
"content": content, | ||
"commit_message": "Initial commit", | ||
} | ||
|
||
|
||
@pytest.mark.skipif(sys.version_info < (3, 8), reason="I am the walrus") | ||
def test_cli_artifacts(capsysbinary, gitlab_config, gitlab_runner, project): | ||
project.files.create(data) | ||
|
||
while not (jobs := project.jobs.list(scope="success")): | ||
time.sleep(0.5) | ||
|
||
job = project.jobs.get(jobs[0].id) | ||
cmd = [ | ||
"gitlab", | ||
"--config-file", | ||
gitlab_config, | ||
"project-job", | ||
"artifacts", | ||
"--id", | ||
str(job.id), | ||
"--project-id", | ||
str(project.id), | ||
] | ||
|
||
with capsysbinary.disabled(): | ||
artifacts = subprocess.check_output(cmd) | ||
assert isinstance(artifacts, bytes) | ||
|
||
artifacts_zip = BytesIO(artifacts) | ||
assert is_zipfile(artifacts_zip) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters