|
28 | 28 | from chip.clusters.Attribute import EventReadResult, SubscriptionTransaction
|
29 | 29 | from chip.clusters.Types import NullValue
|
30 | 30 | from chip.interaction_model import InteractionModelError, Status
|
31 |
| -from matter_testing_support import EventChangeCallback, TestStep |
| 31 | +from matter_testing_support import ClusterAttributeChangeAccumulator, EventChangeCallback, TestStep |
32 | 32 | from mobly import asserts
|
33 | 33 |
|
34 | 34 |
|
@@ -1082,6 +1082,7 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1):
|
1082 | 1082 |
|
1083 | 1083 | # STEP 7: TH waits for initial-countdown-time
|
1084 | 1084 | self.step(7)
|
| 1085 | + logging.info(f'Sleeping for {initial_countdown_time:.1f} seconds.') |
1085 | 1086 | time.sleep(initial_countdown_time)
|
1086 | 1087 |
|
1087 | 1088 | # STEP 8: TH sends Stop command to the DUT
|
@@ -1221,3 +1222,112 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1):
|
1221 | 1222 | self.skip_step(20)
|
1222 | 1223 | self.skip_step(21)
|
1223 | 1224 | self.skip_step(22)
|
| 1225 | + |
| 1226 | + ############################ |
| 1227 | + # TEST CASE 2.6 - Optional Reports with DUT as Server |
| 1228 | + ############################ |
| 1229 | + def steps_TC_OPSTATE_BASE_2_6(self) -> list[TestStep]: |
| 1230 | + steps = [TestStep(1, "Commissioning, already done", is_commissioning=True), |
| 1231 | + TestStep(2, "Subscribe to CountdownTime attribute"), |
| 1232 | + TestStep(3, "Manually put the DUT into a state where it will use the CountdownTime attribute, " |
| 1233 | + "the initial value of the CountdownTime is greater than 30, " |
| 1234 | + "and it will begin counting down the CountdownTime attribute."), |
| 1235 | + TestStep(4, "Over a period of 30 seconds, TH counts all report transactions with an attribute " |
| 1236 | + "report for the CountdownTime attribute in numberOfReportsReceived"), |
| 1237 | + TestStep(5, "Until the current operation finishes, TH counts all report transactions with " |
| 1238 | + "an attribute report for the CountdownTime attribute in numberOfReportsReceived and saves up to 5 such reports."), |
| 1239 | + TestStep(6, "Manually put the DUT into a state where it will use the CountdownTime attribute, " |
| 1240 | + "the initial value of the CountdownTime is greater than 30, and it will begin counting down the CountdownTime attribute."), |
| 1241 | + TestStep(7, "TH reads from the DUT the OperationalState attribute"), |
| 1242 | + TestStep(8, "Manually put the device in the Paused(0x02) operational state") |
| 1243 | + ] |
| 1244 | + return steps |
| 1245 | + |
| 1246 | + async def TEST_TC_OPSTATE_BASE_2_6(self, endpoint=1): |
| 1247 | + cluster = self.test_info.cluster |
| 1248 | + attributes = cluster.Attributes |
| 1249 | + |
| 1250 | + self.init_test() |
| 1251 | + |
| 1252 | + # commission |
| 1253 | + self.step(1) |
| 1254 | + |
| 1255 | + # Note that this does a subscribe-all instead of subscribing only to the CountdownTime attribute. |
| 1256 | + # To-Do: Update the TP to subscribe-all. |
| 1257 | + self.step(2) |
| 1258 | + sub_handler = ClusterAttributeChangeAccumulator(cluster) |
| 1259 | + await sub_handler.start(self.default_controller, self.dut_node_id, endpoint) |
| 1260 | + |
| 1261 | + self.step(3) |
| 1262 | + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ST_RUNNING")): |
| 1263 | + self.send_manual_or_pipe_command(name="OperationalStateChange", |
| 1264 | + device=self.device, |
| 1265 | + operation="Start") |
| 1266 | + time.sleep(1) |
| 1267 | + await self.read_and_expect_value(endpoint=endpoint, |
| 1268 | + attribute=attributes.OperationalState, |
| 1269 | + expected_value=cluster.Enums.OperationalStateEnum.kRunning) |
| 1270 | + count = sub_handler.attribute_report_counts[attributes.CountdownTime] |
| 1271 | + asserts.assert_greater(count, 0, "Did not receive any reports for CountdownTime") |
| 1272 | + else: |
| 1273 | + self.skip_step(3) |
| 1274 | + |
| 1275 | + sub_handler.reset() |
| 1276 | + self.step(4) |
| 1277 | + logging.info('Test will now collect data for 30 seconds') |
| 1278 | + time.sleep(30) |
| 1279 | + |
| 1280 | + count = sub_handler.attribute_report_counts[attributes.CountdownTime] |
| 1281 | + sub_handler.reset() |
| 1282 | + asserts.assert_less_equal(count, 5, "Received more than 5 reports for CountdownTime") |
| 1283 | + asserts.assert_greater_equal(count, 0, "Did not receive any reports for CountdownTime") |
| 1284 | + |
| 1285 | + attr_value = await self.read_expect_success( |
| 1286 | + endpoint=endpoint, |
| 1287 | + attribute=attributes.OperationalState) |
| 1288 | + if attr_value == cluster.Enums.OperationalStateEnum.kRunning: |
| 1289 | + self.step(5) |
| 1290 | + wait_count = 0 |
| 1291 | + while (attr_value != cluster.Enums.OperationalStateEnum.kStopped) and (wait_count < 20): |
| 1292 | + time.sleep(1) |
| 1293 | + wait_count = wait_count + 1 |
| 1294 | + attr_value = await self.read_expect_success( |
| 1295 | + endpoint=endpoint, |
| 1296 | + attribute=attributes.OperationalState) |
| 1297 | + count = sub_handler.attribute_report_counts[attributes.CountdownTime] |
| 1298 | + asserts.assert_less_equal(count, 5, "Received more than 5 reports for CountdownTime") |
| 1299 | + asserts.assert_greater(count, 0, "Did not receive any reports for CountdownTime") |
| 1300 | + else: |
| 1301 | + self.skip_step(5) |
| 1302 | + |
| 1303 | + sub_handler.reset() |
| 1304 | + self.step(6) |
| 1305 | + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ST_RUNNING")): |
| 1306 | + self.send_manual_or_pipe_command(name="OperationalStateChange", |
| 1307 | + device=self.device, |
| 1308 | + operation="Start") |
| 1309 | + time.sleep(1) |
| 1310 | + await self.read_and_expect_value(endpoint=endpoint, |
| 1311 | + attribute=attributes.OperationalState, |
| 1312 | + expected_value=cluster.Enums.OperationalStateEnum.kRunning) |
| 1313 | + count = sub_handler.attribute_report_counts[attributes.CountdownTime] |
| 1314 | + asserts.assert_greater(count, 0, "Did not receive any reports for CountdownTime") |
| 1315 | + else: |
| 1316 | + self.skip_step(6) |
| 1317 | + |
| 1318 | + self.step(7) |
| 1319 | + await self.read_and_expect_value(endpoint=endpoint, |
| 1320 | + attribute=attributes.OperationalState, |
| 1321 | + expected_value=cluster.Enums.OperationalStateEnum.kRunning) |
| 1322 | + |
| 1323 | + sub_handler.reset() |
| 1324 | + self.step(8) |
| 1325 | + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ST_PAUSED")): |
| 1326 | + self.send_manual_or_pipe_command(name="OperationalStateChange", |
| 1327 | + device=self.device, |
| 1328 | + operation="Pause") |
| 1329 | + time.sleep(1) |
| 1330 | + count = sub_handler.attribute_report_counts[attributes.CountdownTime] |
| 1331 | + asserts.assert_greater(count, 0, "Did not receive any reports for CountdownTime") |
| 1332 | + else: |
| 1333 | + self.skip_step(8) |
0 commit comments