aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichal Jagiello <michal.jagiello@t-mobile.pl>2020-10-06 09:56:13 +0000
committerMichal Jagiello <michal.jagiello@t-mobile.pl>2020-10-06 10:25:28 +0000
commit84a44a0cf70e2e55a13e4e994836ee074b7039aa (patch)
tree4a5cd2706061e5147381f87874197777448d85ca /tests
parentc166b498dd792bafc22672d56c15abc5714898ab (diff)
Collect steps execution result
Create a decorator to collect step execution result and store them in storage class. Storage class prepare a dictionary with step class name and execution result. Issue-ID: INT-1733 Change-Id: I9c4030a0740085a9acca461c1581683c469ecbcf Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_reports_collection.py10
-rw-r--r--tests/test_store_state.py29
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_reports_collection.py b/tests/test_reports_collection.py
new file mode 100644
index 0000000..264b6b4
--- /dev/null
+++ b/tests/test_reports_collection.py
@@ -0,0 +1,10 @@
+
+from onaptests.steps.reports_collection import ReportsCollection
+
+
+def test_reports_collection():
+ rc = ReportsCollection()
+ assert rc.report == {}
+
+ rc.put({"a": "b"})
+ assert rc.report == {"a": "b"}
diff --git a/tests/test_store_state.py b/tests/test_store_state.py
new file mode 100644
index 0000000..e0c8b6b
--- /dev/null
+++ b/tests/test_store_state.py
@@ -0,0 +1,29 @@
+import pytest
+from onaptests.steps.base import BaseStep
+
+
+class TestStep(BaseStep):
+
+ @BaseStep.store_state
+ def execute(self):
+ return super().execute()
+
+
+class TestFailStep(BaseStep):
+
+ @BaseStep.store_state
+ def execute(self):
+ super().execute()
+ raise Exception
+
+
+def test_store_state():
+ ts = TestStep()
+ ts.execute()
+ assert ts.reports_collection.report == {"TestStep": "PASS"}
+
+ fs = TestFailStep()
+ fs.add_step(TestStep())
+ with pytest.raises(Exception):
+ fs.execute()
+ fs.reports_collection.report == {"TestFailStep": "FAIL", "TestStep": "PASS"}