summaryrefslogtreecommitdiff
path: root/tests/unit/objects
diff options
context:
space:
mode:
authorRaphaƫl Monat <raphael.monat@lip6.fr>2020-12-10 18:33:24 +0100
committerNejc Habjan <hab.nejc@gmail.com>2021-05-29 22:40:51 +0200
commitee9f96e61ab5da0ecf469c21cccaafc89130a896 (patch)
tree1521454c3fa9da89eba68547b5fb9aebb044595e /tests/unit/objects
parent861d3d28ebca719d06bb004556daa12c24ffec72 (diff)
downloadgitlab-ee9f96e61ab5da0ecf469c21cccaafc89130a896.tar.gz
feat(objects): add pipeline test report support
Diffstat (limited to 'tests/unit/objects')
-rw-r--r--tests/unit/objects/test_pipelines.py54
1 files changed, 53 insertions, 1 deletions
diff --git a/tests/unit/objects/test_pipelines.py b/tests/unit/objects/test_pipelines.py
index d474296..c0b87f2 100644
--- a/tests/unit/objects/test_pipelines.py
+++ b/tests/unit/objects/test_pipelines.py
@@ -4,7 +4,7 @@ GitLab API: https://docs.gitlab.com/ee/api/pipelines.html
import pytest
import responses
-from gitlab.v4.objects import ProjectPipeline
+from gitlab.v4.objects import ProjectPipeline, ProjectPipelineTestReport
pipeline_content = {
"id": 46,
@@ -35,6 +35,37 @@ pipeline_content = {
}
+test_report_content = {
+ "total_time": 5,
+ "total_count": 1,
+ "success_count": 1,
+ "failed_count": 0,
+ "skipped_count": 0,
+ "error_count": 0,
+ "test_suites": [
+ {
+ "name": "Secure",
+ "total_time": 5,
+ "total_count": 1,
+ "success_count": 1,
+ "failed_count": 0,
+ "skipped_count": 0,
+ "error_count": 0,
+ "test_cases": [
+ {
+ "status": "success",
+ "name": "Security Reports can create an auto-remediation MR",
+ "classname": "vulnerability_management_spec",
+ "execution_time": 5,
+ "system_output": None,
+ "stack_trace": None,
+ }
+ ],
+ }
+ ],
+}
+
+
@pytest.fixture
def resp_get_pipeline():
with responses.RequestsMock() as rsps:
@@ -74,6 +105,19 @@ def resp_retry_pipeline():
yield rsps
+@pytest.fixture
+def resp_get_pipeline_test_report():
+ with responses.RequestsMock() as rsps:
+ rsps.add(
+ method=responses.GET,
+ url="http://localhost/api/v4/projects/1/pipelines/1/test_report",
+ json=test_report_content,
+ content_type="application/json",
+ status=200,
+ )
+ yield rsps
+
+
def test_get_project_pipeline(project, resp_get_pipeline):
pipeline = project.pipelines.get(1)
assert isinstance(pipeline, ProjectPipeline)
@@ -92,3 +136,11 @@ def test_retry_project_pipeline(project, resp_retry_pipeline):
output = pipeline.retry()
assert output["ref"] == "master"
+
+
+def test_get_project_pipeline_test_report(project, resp_get_pipeline_test_report):
+ pipeline = project.pipelines.get(1, lazy=True)
+ test_report = pipeline.test_report.get()
+ assert isinstance(test_report, ProjectPipelineTestReport)
+ assert test_report.total_time == 5
+ assert test_report.test_suites[0]["name"] == "Secure"