Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit090ed9a

Browse files
committed
test: application statistics
1 parentc01eb90 commit090ed9a

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

‎docs/gl_objects/statistics.rst‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
##########
2+
Statistics
3+
##########
4+
5+
Reference
6+
---------
7+
8+
* v4 API:
9+
10+
+:class:`gitlab.v4.objects.ApplicationStatistics`
11+
+:class:`gitlab.v4.objects.ApplicationStatisticsManager`
12+
+:attr:`gitlab.Gitlab.statistics`
13+
14+
* GitLab API: https://docs.gitlab.com/ee/api/statistics.html
15+
16+
Examples
17+
--------
18+
19+
Get the statistics::
20+
21+
statistics = gl.statistics.get()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
GitLab API: https://docs.gitlab.com/ee/api/statistics.html
3+
"""
4+
5+
6+
deftest_get_statistics(gl,resp_application_statistics):
7+
gl.projects.create({"name":"admin_project"})
8+
gl.users.create(
9+
{
10+
"email":"user@test.com",
11+
"username":"user",
12+
"name":"user",
13+
"password":"user_pass",
14+
}
15+
)
16+
gl.groups.create({"name":"gitlab-test-group1","path":"gitlab-test-group1"})
17+
gl.snippets.create(
18+
{"title":"snippet1","file_name":"snippet1.py","content":"import gitlab"}
19+
)
20+
21+
statistics=gl.statistics.get()
22+
assertstatistics.snippets==1
23+
assertstatistics.users==1
24+
assertstatistics.groups==1
25+
assertstatistics.projects==1
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""
2+
GitLab API: https://docs.gitlab.com/ee/api/statistics.html
3+
"""
4+
5+
importpytest
6+
importresponses
7+
8+
content= {
9+
"forks":"10",
10+
"issues":"76",
11+
"merge_requests":"27",
12+
"notes":"954",
13+
"snippets":"50",
14+
"ssh_keys":"10",
15+
"milestones":"40",
16+
"users":"50",
17+
"groups":"10",
18+
"projects":"20",
19+
"active_users":"50",
20+
}
21+
22+
23+
@pytest.fixture
24+
defresp_application_statistics():
25+
26+
withresponses.RequestsMock(assert_all_requests_are_fired=False)asrsps:
27+
rsps.add(
28+
method=responses.GET,
29+
url="http://localhost/api/v4/application/statistics",
30+
json=content,
31+
content_type="application/json",
32+
status=200,
33+
)
34+
35+
yieldrsps
36+
37+
38+
deftest_get_statistics(gl,resp_application_statistics):
39+
statistics=gl.statistics.get()
40+
assertstatistics.forks==content["forks"]
41+
assertstatistics.merge_requests==content["merge_requests"]
42+
assertstatistics.notes==content["notes"]
43+
assertstatistics.snippets==content["snippets"]
44+
assertstatistics.ssh_keys==content["ssh_keys"]
45+
assertstatistics.milestones==content["milestones"]
46+
assertstatistics.users==content["users"]
47+
assertstatistics.groups==content["groups"]
48+
assertstatistics.projects==content["projects"]
49+
assertstatistics.active_users==content["active_users"]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp