11"""
22GitLab API: https://docs.gitlab.com/ce/api/issues.html
33"""
4+ import re
45
56import pytest
67import responses
78
8- from gitlab .v4 .objects import ProjectIssuesStatistics
9+ from gitlab .v4 .objects import (
10+ GroupIssuesStatistics ,
11+ IssuesStatistics ,
12+ ProjectIssuesStatistics ,
13+ )
914
1015
1116@pytest .fixture
@@ -43,7 +48,9 @@ def resp_issue_statistics():
4348 with responses .RequestsMock () as rsps :
4449 rsps .add (
4550 method = responses .GET ,
46- url = "http://localhost/api/v4/projects/1/issues_statistics" ,
51+ url = re .compile (
52+ r"http://localhost/api/v4/((groups|projects)/1/)?issues_statistics"
53+ ),
4754 json = content ,
4855 content_type = "application/json" ,
4956 status = 200 ,
@@ -63,7 +70,19 @@ def test_get_issue(gl, resp_get_issue):
6370 assert issue .name == "name"
6471
6572
66- def test_project_issues_statistics (project , resp_issue_statistics ):
73+ def test_get_issues_statistics (gl , resp_issue_statistics ):
74+ statistics = gl .issuesstatistics .get ()
75+ assert isinstance (statistics , IssuesStatistics )
76+ assert statistics .statistics ["counts" ]["all" ] == 20
77+
78+
79+ def test_get_group_issues_statistics (group , resp_issue_statistics ):
80+ statistics = group .issuesstatistics .get ()
81+ assert isinstance (statistics , GroupIssuesStatistics )
82+ assert statistics .statistics ["counts" ]["all" ] == 20
83+
84+
85+ def test_get_project_issues_statistics (project , resp_issue_statistics ):
6786 statistics = project .issuesstatistics .get ()
6887 assert isinstance (statistics , ProjectIssuesStatistics )
6988 assert statistics .statistics ["counts" ]["all" ] == 20
0 commit comments