Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7327f78

Browse files
nejchJohnVillalovos
authored andcommitted
test(cli): improve coverage for custom actions
1 parent98ccc3c commit7327f78

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

‎requirements-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ coverage
22
pytest==7.1.2
33
pytest-console-scripts==1.3.1
44
pytest-cov
5+
PyYaml>=5.2
56
responses

‎tests/functional/cli/test_cli.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
importpytest
1010
importresponses
11+
importyaml
1112

1213
fromgitlabimport__version__,config
1314
fromgitlab.constimportDEFAULT_URL
@@ -135,11 +136,36 @@ def test_invalid_auth_config(script_runner, monkeypatch, fixture_dir):
135136
assert"401"inret.stderr
136137

137138

138-
deftest_fields(gitlab_cli,project_file):
139-
cmd="-o","json","--fields","default_branch","project","list"
139+
format_matrix= [
140+
("json",json.loads),
141+
("yaml",yaml.safe_load),
142+
]
143+
144+
145+
@pytest.mark.parametrize("format,loader",format_matrix)
146+
deftest_cli_display(gitlab_cli,project,format,loader):
147+
cmd= ["-o",format,"project","get","--id",project.id]
148+
149+
ret=gitlab_cli(cmd)
150+
assertret.success
151+
152+
content=loader(ret.stdout.strip())
153+
assertcontent["id"]==project.id
154+
155+
156+
@pytest.mark.parametrize("format,loader",format_matrix)
157+
deftest_cli_fields_in_list(gitlab_cli,project_file,format,loader):
158+
cmd= [
159+
"-o",
160+
format,
161+
"--fields",
162+
"default_branch",
163+
"project",
164+
"list",
165+
]
140166

141167
ret=gitlab_cli(cmd)
142168
assertret.success
143169

144-
content=json.loads(ret.stdout.strip())
170+
content=loader(ret.stdout.strip())
145171
assert ["default_branch"initemforitemincontent]

‎tests/functional/cli/test_cli_projects.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def project_export(project):
4646
returnexport
4747

4848

49-
deftest_project_export_download(gitlab_config,project_export):
49+
deftest_project_export_download_custom_action(gitlab_config,project_export):
50+
"""Tests custom action on ProjectManager"""
5051
cmd= [
5152
"gitlab",
5253
"--config-file",
@@ -59,3 +60,10 @@ def test_project_export_download(gitlab_config, project_export):
5960

6061
export=subprocess.run(cmd,capture_output=True,check=True)
6162
assertexport.returncode==0
63+
64+
65+
deftest_project_languages_custom_action(gitlab_cli,project,project_file):
66+
"""Tests custom action on Project/RESTObject"""
67+
cmd= ["project","languages","--id",project.id]
68+
ret=gitlab_cli(cmd)
69+
assertret.success

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp