aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_store_state.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_store_state.py')
-rw-r--r--tests/test_store_state.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/test_store_state.py b/tests/test_store_state.py
index f5fcc62..8b3a728 100644
--- a/tests/test_store_state.py
+++ b/tests/test_store_state.py
@@ -1,3 +1,5 @@
+from time import sleep
+
import pytest
from onaptests.steps.base import BaseStep
@@ -35,6 +37,37 @@ class TestFailStep(BaseStep):
return "Test"
+class TestOneSecStep(BaseStep):
+
+ @BaseStep.store_state
+ def execute(self):
+ super().execute()
+ sleep(1)
+
+ @property
+ def description(self):
+ return "One second test step"
+
+ @property
+ def component(self) -> str:
+ return "Test"
+
+
+class TestStepNoSuperExecute(BaseStep):
+
+ @BaseStep.store_state
+ def execute(self):
+ sleep(1)
+
+ @property
+ def description(self):
+ return "One second test step - no super execute call"
+
+ @property
+ def component(self) -> str:
+ return "Test"
+
+
def test_store_state():
ts = TestStep()
ts.execute()
@@ -56,3 +89,26 @@ def test_store_state():
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
+
+
+def test_store_state_time_measurement():
+
+ ts = TestOneSecStep()
+ ts.execute()
+ assert len(ts.reports_collection.report) == 1
+ rep = ts.reports_collection.report[0]
+ assert rep.step_execution_duration > 1
+
+ ts = TestOneSecStep()
+ ts.add_step(TestOneSecStep())
+ ts.execute()
+ assert len(ts.reports_collection.report) == 2
+ rep_one, rep_two = ts.reports_collection.report
+ assert rep_one.step_execution_duration > 1 and rep_one.step_execution_duration < 2
+ assert rep_two.step_execution_duration > 1 and rep_two.step_execution_duration < 2
+
+ ts = TestStepNoSuperExecute()
+ ts.execute()
+ assert len(ts.reports_collection.report) == 1
+ rep = ts.reports_collection.report[0]
+ assert rep.step_execution_duration < 1