aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichal Jagiello <michal.jagiello@t-mobile.pl>2021-01-12 20:30:16 +0000
committerMichal Jagiello <michal.jagiello@t-mobile.pl>2021-01-12 20:39:04 +0000
commit1b5383b287358f97ecee424b3dc9432c519e1090 (patch)
treefb4c7d7fa1a3565c8d79eeff5710df741d94c886 /tests
parentd089e89005df1b4b3b6238a2937e23791c07d9ae (diff)
Fix steps time measurement
Substeps execution time is not stored with the right time of step execution Issue-ID: TEST-292 Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl> Change-Id: I58e2aecb1f3cfb1a2bf78a438fc3d508ecf83cc1
Diffstat (limited to 'tests')
-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