summaryrefslogtreecommitdiff
path: root/tests/unit/objects/test_statistics.py
blob: c7ace57310cd602f4862c1e1ff61963d93764898 (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
"""
GitLab API: https://docs.gitlab.com/ee/api/statistics.html
"""

import pytest
import responses

content = {
    "forks": "10",
    "issues": "76",
    "merge_requests": "27",
    "notes": "954",
    "snippets": "50",
    "ssh_keys": "10",
    "milestones": "40",
    "users": "50",
    "groups": "10",
    "projects": "20",
    "active_users": "50",
}


@pytest.fixture
def resp_application_statistics():
    with responses.RequestsMock() as rsps:
        rsps.add(
            method=responses.GET,
            url="http://localhost/api/v4/application/statistics",
            json=content,
            content_type="application/json",
            status=200,
        )

        yield rsps


def test_get_statistics(gl, resp_application_statistics):
    statistics = gl.statistics.get()
    assert statistics.forks == content["forks"]
    assert statistics.merge_requests == content["merge_requests"]
    assert statistics.notes == content["notes"]
    assert statistics.snippets == content["snippets"]
    assert statistics.ssh_keys == content["ssh_keys"]
    assert statistics.milestones == content["milestones"]
    assert statistics.users == content["users"]
    assert statistics.groups == content["groups"]
    assert statistics.projects == content["projects"]
    assert statistics.active_users == content["active_users"]