diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/functional/cli/conftest.py | 14 | ||||
-rw-r--r-- | tests/functional/cli/test_cli.py | 11 | ||||
-rw-r--r-- | tests/functional/cli/test_cli_variables.py | 35 |
3 files changed, 49 insertions, 11 deletions
diff --git a/tests/functional/cli/conftest.py b/tests/functional/cli/conftest.py index ba94dcb..4311339 100644 --- a/tests/functional/cli/conftest.py +++ b/tests/functional/cli/conftest.py @@ -1,4 +1,7 @@ import pytest +import responses + +from gitlab.const import DEFAULT_URL @pytest.fixture @@ -19,3 +22,14 @@ def gitlab_cli(script_runner, gitlab_config): return script_runner.run(*command) return _gitlab_cli + + +@pytest.fixture +def resp_get_project(): + return { + "method": responses.GET, + "url": f"{DEFAULT_URL}/api/v4/projects/1", + "json": {"name": "name", "path": "test-path", "id": 1}, + "content_type": "application/json", + "status": 200, + } diff --git a/tests/functional/cli/test_cli.py b/tests/functional/cli/test_cli.py index 97ecacb..a889066 100644 --- a/tests/functional/cli/test_cli.py +++ b/tests/functional/cli/test_cli.py @@ -17,17 +17,6 @@ CI_JOB_TOKEN = "ci-job-token" CI_SERVER_URL = "https://gitlab.example.com" -@pytest.fixture -def resp_get_project(): - return { - "method": responses.GET, - "url": f"{DEFAULT_URL}/api/v4/projects/1", - "json": {"name": "name", "path": "test-path", "id": 1}, - "content_type": "application/json", - "status": 200, - } - - def test_main_entrypoint(script_runner, gitlab_config): ret = script_runner.run("python", "-m", "gitlab", "--config-file", gitlab_config) assert ret.returncode == 2 diff --git a/tests/functional/cli/test_cli_variables.py b/tests/functional/cli/test_cli_variables.py index 9b1b16d..5195f16 100644 --- a/tests/functional/cli/test_cli_variables.py +++ b/tests/functional/cli/test_cli_variables.py @@ -1,3 +1,12 @@ +import copy + +import pytest +import responses + +from gitlab import config +from gitlab.const import DEFAULT_URL + + def test_list_instance_variables(gitlab_cli, gl): cmd = ["variable", "list"] ret = gitlab_cli(cmd) @@ -17,3 +26,29 @@ def test_list_project_variables(gitlab_cli, project): ret = gitlab_cli(cmd) assert ret.success + + +def test_list_project_variables_with_path(gitlab_cli, project): + cmd = ["project-variable", "list", "--project-id", project.path_with_namespace] + ret = gitlab_cli(cmd) + + assert ret.success + + +@pytest.mark.script_launch_mode("inprocess") +@responses.activate +def test_list_project_variables_with_path_url_check( + monkeypatch, script_runner, resp_get_project +): + monkeypatch.setattr(config, "_DEFAULT_FILES", []) + resp_get_project_variables = copy.deepcopy(resp_get_project) + resp_get_project_variables.update( + url=f"{DEFAULT_URL}/api/v4/projects/project%2Fwith%2Fa%2Fnamespace/variables" + ) + resp_get_project_variables.update(json=[]) + + responses.add(**resp_get_project_variables) + ret = script_runner.run( + "gitlab", "project-variable", "list", "--project-id", "project/with/a/namespace" + ) + assert ret.success |