summaryrefslogtreecommitdiff
path: root/tests/functional/cli/test_cli_projects.py
blob: 8c7587f672535871e13c0d991b3e497895f943bc (plain)
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
import subprocess
import time

import pytest
import responses


@pytest.mark.script_launch_mode("inprocess")
@responses.activate
def test_project_registry_delete_in_bulk(
    script_runner, resp_delete_registry_tags_in_bulk
):
    responses.add(**resp_delete_registry_tags_in_bulk)
    cmd = [
        "gitlab",
        "project-registry-tag",
        "delete-in-bulk",
        "--project-id",
        "1",
        "--repository-id",
        "1",
        "--name-regex-delete",
        "^.*dev.*$",
        # TODO: remove `name` after deleting without ID is possible
        # See #849 and #1631
        "--name",
        ".*",
    ]
    ret = ret = script_runner.run(*cmd)
    assert ret.success


@pytest.fixture
def project_export(project):
    export = project.exports.create()
    export.refresh()

    count = 0
    while export.export_status != "finished":
        time.sleep(0.5)
        export.refresh()
        count += 1
        if count == 30:
            raise Exception("Project export taking too much time")

    return export


def test_project_export_download_custom_action(gitlab_config, project_export):
    """Tests custom action on ProjectManager"""
    cmd = [
        "gitlab",
        "--config-file",
        gitlab_config,
        "project-export",
        "download",
        "--project-id",
        str(project_export.id),
    ]

    export = subprocess.run(cmd, capture_output=True, check=True)
    assert export.returncode == 0


def test_project_languages_custom_action(gitlab_cli, project, project_file):
    """Tests custom action on Project/RESTObject"""
    cmd = ["project", "languages", "--id", project.id]
    ret = gitlab_cli(cmd)
    assert ret.success