summaryrefslogtreecommitdiff
path: root/tests/unit/objects/test_registry_repositories.py
blob: 61929172b8e8c9790ff965579225ddd3326f0ea7 (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
"""
GitLab API: https://docs.gitlab.com/ee/api/container_registry.html
"""
import pytest
import responses

from gitlab.v4.objects import ProjectRegistryRepository

repositories_content = [
    {
        "id": 1,
        "name": "",
        "path": "group/project",
        "project_id": 9,
        "location": "gitlab.example.com:5000/group/project",
        "created_at": "2019-01-10T13:38:57.391Z",
        "cleanup_policy_started_at": "2020-01-10T15:40:57.391Z",
    },
    {
        "id": 2,
        "name": "releases",
        "path": "group/project/releases",
        "project_id": 9,
        "location": "gitlab.example.com:5000/group/project/releases",
        "created_at": "2019-01-10T13:39:08.229Z",
        "cleanup_policy_started_at": "2020-08-17T03:12:35.489Z",
    },
]


@pytest.fixture
def resp_group_registry_repositories():
    with responses.RequestsMock() as rsps:
        rsps.add(
            method=responses.GET,
            url="http://localhost/api/v4/groups/1/registry/repositories",
            json=repositories_content,
            content_type="application/json",
            status=200,
        )
        yield rsps


def test_list_group_registry_repositories(group, resp_group_registry_repositories):
    repositories = group.registry_repositories.list()
    assert isinstance(repositories[0], ProjectRegistryRepository)
    assert repositories[0].id == 1