File: test_cli_variables.py

package info (click to toggle)
python-gitlab 1%3A4.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,048 kB
  • sloc: python: 24,168; makefile: 171; ruby: 27; javascript: 3
file content (56 lines) | stat: -rw-r--r-- 1,416 bytes parent folder | download
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
import copy

import pytest
import responses

from gitlab.const import DEFAULT_URL


def test_list_instance_variables(gitlab_cli, gl):
    cmd = ["variable", "list"]
    ret = gitlab_cli(cmd)

    assert ret.success


def test_list_group_variables(gitlab_cli, group):
    cmd = ["group-variable", "list", "--group-id", group.id]
    ret = gitlab_cli(cmd)

    assert ret.success


def test_list_project_variables(gitlab_cli, project):
    cmd = ["project-variable", "list", "--project-id", project.id]
    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(script_runner, resp_get_project):
    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