Skip to content

Commit 1ca8115

Browse files
committed
TC-OPSTATE-2.5,6: Fix messages, re-establish subscription after reset
1 parent 792895d commit 1ca8115

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

src/python_testing/TC_OpstateCommon.py

+25-13
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,16 @@ def init_test(self):
111111
asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set")
112112
self.app_pipe = self.app_pipe + str(app_pid)
113113

114-
def send_raw_manual_or_pipe_command(self, command: dict):
114+
def send_raw_manual_or_pipe_command(self, command: dict, msg: str):
115115
if self.is_ci:
116116
self.write_to_app_pipe(command)
117117
time.sleep(0.1)
118118
else:
119-
self.wait_for_user_input(prompt_msg="Press Enter when ready.\n")
119+
prompt = msg if msg is not None else "Press Enter when ready."
120+
prompt += '\n'
121+
self.wait_for_user_input(prompt_msg=prompt)
120122

121-
def send_manual_or_pipe_command(self, device: str, name: str, operation: str, param: Any = None):
123+
def send_manual_or_pipe_command(self, device: str, name: str, operation: str, param: Any = None, msg=None):
122124
command = {
123125
"Name": name,
124126
"Device": device,
@@ -128,7 +130,7 @@ def send_manual_or_pipe_command(self, device: str, name: str, operation: str, pa
128130
if param is not None:
129131
command["Param"] = param
130132

131-
self.send_raw_manual_or_pipe_command(command)
133+
self.send_raw_manual_or_pipe_command(command, msg)
132134

133135
async def send_cmd(self, endpoint, cmd, timedRequestTimeoutMs=None):
134136
logging.info(f"##### Command {cmd}")
@@ -1046,11 +1048,13 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1):
10461048
self.send_manual_or_pipe_command(name="OperationalStateChange",
10471049
device=self.device,
10481050
operation="OnFault",
1049-
param=cluster.Enums.ErrorStateEnum.kNoError)
1051+
param=cluster.Enums.ErrorStateEnum.kNoError,
1052+
msg="Ensure the DUT is not in an error state.")
10501053

10511054
self.send_manual_or_pipe_command(name="OperationalStateChange",
10521055
device=self.device,
1053-
operation="Stop")
1056+
operation="Stop",
1057+
msg="Put the DUT in a state where it can receive a start command")
10541058

10551059
# STEP 4: TH sends Start command to the DUT
10561060
self.step(4)
@@ -1116,7 +1120,14 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1):
11161120
# reboot outside CI environment.
11171121
if not self.is_ci:
11181122
self.wait_for_user_input(prompt_msg="Restart DUT. Press Enter when ready.\n")
1123+
# Expire the session and re-establish the subscription
11191124
self.default_controller.ExpireSessions(self.dut_node_id)
1125+
if self.check_pics(f"{self.test_info.pics_code}.S.E01"):
1126+
# Subscribe to Events and when they are sent push them to a queue for checking later
1127+
events_callback = EventSpecificChangeCallback(events.OperationCompletion)
1128+
await events_callback.start(self.default_controller,
1129+
self.dut_node_id,
1130+
endpoint)
11201131

11211132
# STEP 12: TH waits for {PIXIT.WAITTIME.REBOOT}
11221133
self.step(12)
@@ -1259,11 +1270,12 @@ async def TEST_TC_OPSTATE_BASE_2_6(self, endpoint=1):
12591270
sub_handler = ClusterAttributeChangeAccumulator(cluster)
12601271
await sub_handler.start(self.default_controller, self.dut_node_id, endpoint)
12611272

1273+
self.step(3)
12621274
if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ST_RUNNING")):
1263-
self.step(3)
12641275
self.send_manual_or_pipe_command(name="OperationalStateChange",
12651276
device=self.device,
1266-
operation="Start")
1277+
operation="Start",
1278+
msg="Put the DUT into the running state")
12671279
time.sleep(1)
12681280
await self.read_and_expect_value(endpoint=endpoint,
12691281
attribute=attributes.OperationalState,
@@ -1272,8 +1284,6 @@ async def TEST_TC_OPSTATE_BASE_2_6(self, endpoint=1):
12721284
if countdownTime is not NullValue:
12731285
count = sub_handler.attribute_report_counts[attributes.CountdownTime]
12741286
asserts.assert_greater(count, 0, "Did not receive any reports for CountdownTime")
1275-
else:
1276-
self.skip_step(3)
12771287

12781288
sub_handler.reset()
12791289
self.step(4)
@@ -1311,11 +1321,12 @@ async def TEST_TC_OPSTATE_BASE_2_6(self, endpoint=1):
13111321
self.skip_step(7)
13121322

13131323
sub_handler.reset()
1324+
self.step(8)
13141325
if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ST_RUNNING")):
1315-
self.step(8)
13161326
self.send_manual_or_pipe_command(name="OperationalStateChange",
13171327
device=self.device,
1318-
operation="Start")
1328+
operation="Start",
1329+
msg="Put DUT in running state")
13191330
time.sleep(1)
13201331
await self.read_and_expect_value(endpoint=endpoint,
13211332
attribute=attributes.OperationalState,
@@ -1339,7 +1350,8 @@ async def TEST_TC_OPSTATE_BASE_2_6(self, endpoint=1):
13391350
self.step(11)
13401351
self.send_manual_or_pipe_command(name="OperationalStateChange",
13411352
device=self.device,
1342-
operation="Pause")
1353+
operation="Pause",
1354+
msg="Put DUT in paused state")
13431355
time.sleep(1)
13441356
count = sub_handler.attribute_report_counts[attributes.CountdownTime]
13451357
asserts.assert_greater(count, 0, "Did not receive any reports for CountdownTime")

0 commit comments

Comments
 (0)