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

Commitee9f96e

Browse files
Raphaël Monatnejch
Raphaël Monat
authored andcommitted
feat(objects): add pipeline test report support
1 parent861d3d2 commitee9f96e

File tree

3 files changed

+90
-1
lines changed

3 files changed

+90
-1
lines changed

‎docs/gl_objects/pipelines_and_jobs.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,3 +326,26 @@ Examples
326326
List bridges for the pipeline::
327327

328328
bridges = pipeline.bridges.list()
329+
330+
Pipeline test report
331+
====================
332+
333+
Get a pipeline's complete test report.
334+
335+
Reference
336+
---------
337+
338+
* v4 API
339+
340+
+:class:`gitlab.v4.objects.ProjectPipelineTestReport`
341+
+:class:`gitlab.v4.objects.ProjectPipelineTestReportManager`
342+
+:attr:`gitlab.v4.objects.ProjectPipeline.test_report`
343+
344+
* GitLab API: https://docs.gitlab.com/ee/api/pipelines.html#get-a-pipelines-test-report
345+
346+
Examples
347+
--------
348+
349+
Get the test report for a pipeline::
350+
351+
test_report = pipeline.test_report.get()

‎gitlab/v4/objects/pipelines.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
CreateMixin,
66
CRUDMixin,
77
DeleteMixin,
8+
GetWithoutIdMixin,
89
ListMixin,
910
ObjectDeleteMixin,
1011
RefreshMixin,
@@ -26,6 +27,8 @@
2627
"ProjectPipelineScheduleVariableManager",
2728
"ProjectPipelineSchedule",
2829
"ProjectPipelineScheduleManager",
30+
"ProjectPipelineTestReport",
31+
"ProjectPipelineTestReportManager",
2932
]
3033

3134

@@ -34,6 +37,7 @@ class ProjectPipeline(RefreshMixin, ObjectDeleteMixin, RESTObject):
3437
("jobs","ProjectPipelineJobManager"),
3538
("bridges","ProjectPipelineBridgeManager"),
3639
("variables","ProjectPipelineVariableManager"),
40+
("test_report","ProjectPipelineTestReportManager"),
3741
)
3842

3943
@cli.register_custom_action("ProjectPipeline")
@@ -201,3 +205,13 @@ class ProjectPipelineScheduleManager(CRUDMixin, RESTManager):
201205
_update_attrs=RequiredOptional(
202206
optional=("description","ref","cron","cron_timezone","active"),
203207
)
208+
209+
210+
classProjectPipelineTestReport(RESTObject):
211+
_id_attr=None
212+
213+
214+
classProjectPipelineTestReportManager(GetWithoutIdMixin,RESTManager):
215+
_path="/projects/%(project_id)s/pipelines/%(pipeline_id)s/test_report"
216+
_obj_cls=ProjectPipelineTestReport
217+
_from_parent_attrs= {"project_id":"project_id","pipeline_id":"id"}

‎tests/unit/objects/test_pipelines.py

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
importpytest
55
importresponses
66

7-
fromgitlab.v4.objectsimportProjectPipeline
7+
fromgitlab.v4.objectsimportProjectPipeline,ProjectPipelineTestReport
88

99
pipeline_content= {
1010
"id":46,
@@ -35,6 +35,37 @@
3535
}
3636

3737

38+
test_report_content= {
39+
"total_time":5,
40+
"total_count":1,
41+
"success_count":1,
42+
"failed_count":0,
43+
"skipped_count":0,
44+
"error_count":0,
45+
"test_suites": [
46+
{
47+
"name":"Secure",
48+
"total_time":5,
49+
"total_count":1,
50+
"success_count":1,
51+
"failed_count":0,
52+
"skipped_count":0,
53+
"error_count":0,
54+
"test_cases": [
55+
{
56+
"status":"success",
57+
"name":"Security Reports can create an auto-remediation MR",
58+
"classname":"vulnerability_management_spec",
59+
"execution_time":5,
60+
"system_output":None,
61+
"stack_trace":None,
62+
}
63+
],
64+
}
65+
],
66+
}
67+
68+
3869
@pytest.fixture
3970
defresp_get_pipeline():
4071
withresponses.RequestsMock()asrsps:
@@ -74,6 +105,19 @@ def resp_retry_pipeline():
74105
yieldrsps
75106

76107

108+
@pytest.fixture
109+
defresp_get_pipeline_test_report():
110+
withresponses.RequestsMock()asrsps:
111+
rsps.add(
112+
method=responses.GET,
113+
url="http://localhost/api/v4/projects/1/pipelines/1/test_report",
114+
json=test_report_content,
115+
content_type="application/json",
116+
status=200,
117+
)
118+
yieldrsps
119+
120+
77121
deftest_get_project_pipeline(project,resp_get_pipeline):
78122
pipeline=project.pipelines.get(1)
79123
assertisinstance(pipeline,ProjectPipeline)
@@ -92,3 +136,11 @@ def test_retry_project_pipeline(project, resp_retry_pipeline):
92136

93137
output=pipeline.retry()
94138
assertoutput["ref"]=="master"
139+
140+
141+
deftest_get_project_pipeline_test_report(project,resp_get_pipeline_test_report):
142+
pipeline=project.pipelines.get(1,lazy=True)
143+
test_report=pipeline.test_report.get()
144+
assertisinstance(test_report,ProjectPipelineTestReport)
145+
asserttest_report.total_time==5
146+
asserttest_report.test_suites[0]["name"]=="Secure"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp