| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 861d3d2 commit ee9f96e
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -326,3 +326,26 @@ Examples | |||
| 326 | 326 | List bridges for the pipeline:: | |
| 327 | 327 | ||
| 328 | 328 | 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() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ | |||
| 5 | 5 | CreateMixin, | |
| 6 | 6 | CRUDMixin, | |
| 7 | 7 | DeleteMixin, | |
| 8 | + GetWithoutIdMixin, | ||
| 8 | 9 | ListMixin, | |
| 9 | 10 | ObjectDeleteMixin, | |
| 10 | 11 | RefreshMixin, | |
@@ -26,6 +27,8 @@ | |||
| 26 | 27 | "ProjectPipelineScheduleVariableManager", | |
| 27 | 28 | "ProjectPipelineSchedule", | |
| 28 | 29 | "ProjectPipelineScheduleManager", | |
| 30 | + "ProjectPipelineTestReport", | ||
| 31 | + "ProjectPipelineTestReportManager", | ||
| 29 | 32 | ] | |
| 30 | 33 | ||
| 31 | 34 | ||
@@ -34,6 +37,7 @@ class ProjectPipeline(RefreshMixin, ObjectDeleteMixin, RESTObject): | |||
| 34 | 37 | ("jobs", "ProjectPipelineJobManager"), | |
| 35 | 38 | ("bridges", "ProjectPipelineBridgeManager"), | |
| 36 | 39 | ("variables", "ProjectPipelineVariableManager"), | |
| 40 | + ("test_report", "ProjectPipelineTestReportManager"), | ||
| 37 | 41 | ) | |
| 38 | 42 | ||
| 39 | 43 | @cli.register_custom_action("ProjectPipeline") | |
@@ -201,3 +205,13 @@ class ProjectPipelineScheduleManager(CRUDMixin, RESTManager): | |||
| 201 | 205 | _update_attrs = RequiredOptional( | |
| 202 | 206 | optional=("description", "ref", "cron", "cron_timezone", "active"), | |
| 203 | 207 | ) | |
| 208 | + | ||
| 209 | + | ||
| 210 | + class ProjectPipelineTestReport(RESTObject): | ||
| 211 | + _id_attr = None | ||
| 212 | + | ||
| 213 | + | ||
| 214 | + class ProjectPipelineTestReportManager(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"} | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | import pytest | |
| 5 | 5 | import responses | |
| 6 | 6 | ||
| 7 | - from gitlab.v4.objects import ProjectPipeline | ||
| 7 | + from gitlab.v4.objects import ProjectPipeline, ProjectPipelineTestReport | ||
| 8 | 8 | ||
| 9 | 9 | pipeline_content = { | |
| 10 | 10 | "id": 46, | |
@@ -35,6 +35,37 @@ | |||
| 35 | 35 | } | |
| 36 | 36 | ||
| 37 | 37 | ||
| 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 | + | ||
| 38 | 69 | @pytest.fixture | |
| 39 | 70 | def resp_get_pipeline(): | |
| 40 | 71 | with responses.RequestsMock() as rsps: | |
@@ -74,6 +105,19 @@ def resp_retry_pipeline(): | |||
| 74 | 105 | yield rsps | |
| 75 | 106 | ||
| 76 | 107 | ||
| 108 | + @pytest.fixture | ||
| 109 | + def resp_get_pipeline_test_report(): | ||
| 110 | + with responses.RequestsMock() as rsps: | ||
| 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 | + yield rsps | ||
| 119 | + | ||
| 120 | + | ||
| 77 | 121 | def test_get_project_pipeline(project, resp_get_pipeline): | |
| 78 | 122 | pipeline = project.pipelines.get(1) | |
| 79 | 123 | assert isinstance(pipeline, ProjectPipeline) | |
@@ -92,3 +136,11 @@ def test_retry_project_pipeline(project, resp_retry_pipeline): | |||
| 92 | 136 | ||
| 93 | 137 | output = pipeline.retry() | |
| 94 | 138 | assert output["ref"] == "master" | |
| 139 | + | ||
| 140 | + | ||
| 141 | + def test_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 | + assert isinstance(test_report, ProjectPipelineTestReport) | ||
| 145 | + assert test_report.total_time == 5 | ||
| 146 | + assert test_report.test_suites[0]["name"] == "Secure" | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments