aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichal Jagiello <michal.jagiello@t-mobile.pl>2020-11-03 15:25:58 +0000
committerMichal Jagiello <michal.jagiello@t-mobile.pl>2020-11-04 17:23:40 +0000
commiteeeb7190de7185c9994e460cc0472e8817ab68aa (patch)
treea6385b3748f32b583b326abf016c1b8628bac254 /tests
parent31dc9d07a9bd5c98304ae7d58e995321d3e1507f (diff)
Integration tests report enrichment
Improve the step description for better reporting Add duration step in pythonsdk-test reporting Issue-ID: TEST-271 Issue-ID: TEST-272 Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl> Change-Id: I6d46cb38ae236bc578eb15982c2c0b8f2b0c0791
Diffstat (limited to 'tests')
-rw-r--r--tests/test_reports_collection.py32
-rw-r--r--tests/test_store_state.py33
2 files changed, 59 insertions, 6 deletions
diff --git a/tests/test_reports_collection.py b/tests/test_reports_collection.py
index 264b6b4..8491b91 100644
--- a/tests/test_reports_collection.py
+++ b/tests/test_reports_collection.py
@@ -1,10 +1,34 @@
-from onaptests.steps.reports_collection import ReportsCollection
+from onaptests.steps.reports_collection import Report, ReportsCollection, ReportStepStatus
def test_reports_collection():
rc = ReportsCollection()
- assert rc.report == {}
+ assert rc.report == []
- rc.put({"a": "b"})
- assert rc.report == {"a": "b"}
+ rc.put(Report(
+ "test",
+ ReportStepStatus.PASS,
+ 0.0
+ ))
+ assert len(rc.report) == 1
+
+
+def test_reports_collection_failed_steps_num():
+
+ rc = ReportsCollection()
+ assert rc.failed_steps_num == 0
+
+ rc.put(Report(
+ "test",
+ ReportStepStatus.PASS,
+ 0.0
+ ))
+ assert rc.failed_steps_num == 0
+
+ rc.put(Report(
+ "test",
+ ReportStepStatus.FAIL,
+ 0.0
+ ))
+ assert rc.failed_steps_num == 1
diff --git a/tests/test_store_state.py b/tests/test_store_state.py
index e0c8b6b..f5fcc62 100644
--- a/tests/test_store_state.py
+++ b/tests/test_store_state.py
@@ -1,13 +1,23 @@
import pytest
+
from onaptests.steps.base import BaseStep
+
class TestStep(BaseStep):
@BaseStep.store_state
def execute(self):
return super().execute()
+ @property
+ def description(self):
+ return "Test pass step"
+
+ @property
+ def component(self) -> str:
+ return "Test"
+
class TestFailStep(BaseStep):
@@ -16,14 +26,33 @@ class TestFailStep(BaseStep):
super().execute()
raise Exception
+ @property
+ def description(self):
+ return "Test fail step"
+
+ @property
+ def component(self) -> str:
+ return "Test"
+
def test_store_state():
ts = TestStep()
ts.execute()
- assert ts.reports_collection.report == {"TestStep": "PASS"}
+ assert len(ts.reports_collection.report) == 1
+ rep = ts.reports_collection.report[0]
+ assert rep.step_description == "[Test] TestStep: Test pass step"
+ assert rep.step_execution_status.value == "PASS"
+ assert rep.step_execution_duration != 0
fs = TestFailStep()
fs.add_step(TestStep())
with pytest.raises(Exception):
fs.execute()
- fs.reports_collection.report == {"TestFailStep": "FAIL", "TestStep": "PASS"}
+ rep_f, rep_s = fs.reports_collection.report
+ assert rep_f.step_description == "[Test] TestFailStep: Test fail step"
+ assert rep_f.step_execution_status.value == "FAIL"
+ assert rep_f.step_execution_duration != 0
+
+ assert rep_s.step_description == "[Test] TestStep: Test pass step"
+ assert rep_s.step_execution_status.value == "PASS"
+ assert rep_s.step_execution_duration != 0