| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 98ccc3c commit 7327f78
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,4 +2,5 @@ coverage | |||
| 2 | 2 | pytest==7.1.2 | |
| 3 | 3 | pytest-console-scripts==1.3.1 | |
| 4 | 4 | pytest-cov | |
| 5 | + PyYaml>=5.2 | ||
| 5 | 6 | responses | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | 9 | import pytest | |
| 10 | 10 | import responses | |
| 11 | + import yaml | ||
| 11 | 12 | ||
| 12 | 13 | from gitlab import __version__, config | |
| 13 | 14 | from gitlab.const import DEFAULT_URL | |
@@ -135,11 +136,36 @@ def test_invalid_auth_config(script_runner, monkeypatch, fixture_dir): | |||
| 135 | 136 | assert "401" in ret.stderr | |
| 136 | 137 | ||
| 137 | 138 | ||
| 138 | - def test_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 | + def test_cli_display(gitlab_cli, project, format, loader): | ||
| 147 | + cmd = ["-o", format, "project", "get", "--id", project.id] | ||
| 148 | + | ||
| 149 | + ret = gitlab_cli(cmd) | ||
| 150 | + assert ret.success | ||
| 151 | + | ||
| 152 | + content = loader(ret.stdout.strip()) | ||
| 153 | + assert content["id"] == project.id | ||
| 154 | + | ||
| 155 | + | ||
| 156 | + @pytest.mark.parametrize("format,loader", format_matrix) | ||
| 157 | + def test_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 | + ] | ||
| 140 | 166 | ||
| 141 | 167 | ret = gitlab_cli(cmd) | |
| 142 | 168 | assert ret.success | |
| 143 | 169 | ||
| 144 | - content = json.loads(ret.stdout.strip()) | ||
| 170 | + content = loader(ret.stdout.strip()) | ||
| 145 | 171 | assert ["default_branch" in item for item in content] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,7 +46,8 @@ def project_export(project): | |||
| 46 | 46 | return export | |
| 47 | 47 | ||
| 48 | 48 | ||
| 49 | - def test_project_export_download(gitlab_config, project_export): | ||
| 49 | + def test_project_export_download_custom_action(gitlab_config, project_export): | ||
| 50 | + """Tests custom action on ProjectManager""" | ||
| 50 | 51 | cmd = [ | |
| 51 | 52 | "gitlab", | |
| 52 | 53 | "--config-file", | |
@@ -59,3 +60,10 @@ def test_project_export_download(gitlab_config, project_export): | |||
| 59 | 60 | ||
| 60 | 61 | export = subprocess.run(cmd, capture_output=True, check=True) | |
| 61 | 62 | assert export.returncode == 0 | |
| 63 | + | ||
| 64 | + | ||
| 65 | + def test_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 | + assert ret.success | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments