FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-gitlab/tests/functional/cli/test_cli_artifacts.py at main · rithwikch/python-gitlab · GitHub
rithwikch
python-gitlab
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-gitlab
/
tests
/
functional
/
cli
/
test_cli_artifacts.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
145 lines (121 loc) · 3.59 KB
Breadcrumbs
python-gitlab
/
tests
/
functional
/
cli
/
test_cli_artifacts.py
Copy path
File metadata and controls
145 lines (121 loc) · 3.59 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import
subprocess
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"
:
"main"
,
"content"
:
content
,
"commit_message"
:
"Initial commit"
,
}
@
pytest
.
fixture
(
scope
=
"module"
)
def
job_with_artifacts
(
gitlab_runner
,
project
):
project
.
files
.
create
(
data
)
jobs
=
None
while
not
jobs
:
time
.
sleep
(
0.5
)
jobs
=
project
.
jobs
.
list
(
scope
=
"success"
)
return
project
.
jobs
.
get
(
jobs
[
0
].
id
)
def
test_cli_job_artifacts
(
capsysbinary
,
gitlab_config
,
job_with_artifacts
):
cmd
=
[
"gitlab"
,
"--config-file"
,
gitlab_config
,
"project-job"
,
"artifacts"
,
"--id"
,
str
(
job_with_artifacts
.
id
),
"--project-id"
,
str
(
job_with_artifacts
.
pipeline
[
"project_id"
]),
]
with
capsysbinary
.
disabled
():
artifacts
=
subprocess
.
check_output
(
cmd
)
assert
isinstance
(
artifacts
,
bytes
)
artifacts_zip
=
BytesIO
(
artifacts
)
assert
is_zipfile
(
artifacts_zip
)
def
test_cli_project_artifact_download
(
gitlab_config
,
job_with_artifacts
):
cmd
=
[
"gitlab"
,
"--config-file"
,
gitlab_config
,
"project-artifact"
,
"download"
,
"--project-id"
,
str
(
job_with_artifacts
.
pipeline
[
"project_id"
]),
"--ref-name"
,
job_with_artifacts
.
ref
,
"--job"
,
job_with_artifacts
.
name
,
]
artifacts
=
subprocess
.
run
(
cmd
,
capture_output
=
True
,
check
=
True
)
assert
isinstance
(
artifacts
.
stdout
,
bytes
)
artifacts_zip
=
BytesIO
(
artifacts
.
stdout
)
assert
is_zipfile
(
artifacts_zip
)
def
test_cli_project_artifacts_warns_deprecated
(
gitlab_config
,
job_with_artifacts
):
cmd
=
[
"gitlab"
,
"--config-file"
,
gitlab_config
,
"project"
,
"artifacts"
,
"--id"
,
str
(
job_with_artifacts
.
pipeline
[
"project_id"
]),
"--ref-name"
,
job_with_artifacts
.
ref
,
"--job"
,
job_with_artifacts
.
name
,
]
artifacts
=
subprocess
.
run
(
cmd
,
capture_output
=
True
,
check
=
True
)
assert
isinstance
(
artifacts
.
stdout
,
bytes
)
assert
b"DeprecationWarning"
in
artifacts
.
stderr
artifacts_zip
=
BytesIO
(
artifacts
.
stdout
)
assert
is_zipfile
(
artifacts_zip
)
def
test_cli_project_artifact_raw
(
gitlab_config
,
job_with_artifacts
):
cmd
=
[
"gitlab"
,
"--config-file"
,
gitlab_config
,
"project-artifact"
,
"raw"
,
"--project-id"
,
str
(
job_with_artifacts
.
pipeline
[
"project_id"
]),
"--ref-name"
,
job_with_artifacts
.
ref
,
"--job"
,
job_with_artifacts
.
name
,
"--artifact-path"
,
"artifact.txt"
,
]
artifacts
=
subprocess
.
run
(
cmd
,
capture_output
=
True
,
check
=
True
)
assert
isinstance
(
artifacts
.
stdout
,
bytes
)
assert
artifacts
.
stdout
==
b"test
\n
"
def
test_cli_project_artifact_warns_deprecated
(
gitlab_config
,
job_with_artifacts
):
cmd
=
[
"gitlab"
,
"--config-file"
,
gitlab_config
,
"project"
,
"artifact"
,
"--id"
,
str
(
job_with_artifacts
.
pipeline
[
"project_id"
]),
"--ref-name"
,
job_with_artifacts
.
ref
,
"--job"
,
job_with_artifacts
.
name
,
"--artifact-path"
,
"artifact.txt"
,
]
artifacts
=
subprocess
.
run
(
cmd
,
capture_output
=
True
,
check
=
True
)
assert
isinstance
(
artifacts
.
stdout
,
bytes
)
assert
b"DeprecationWarning"
in
artifacts
.
stderr
assert
artifacts
.
stdout
==
b"test
\n
"
Back
|
FazBrowse Home
|
New Git URL