From f4e242072e48bf94b79816c9c8e8ec83771d8e65 Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Thu, 1 Aug 2024 15:11:14 -0400 Subject: [PATCH] Update ICDM 3.1 Test Script --- src/python_testing/TC_ICDM_3_1.py | 229 ++++++++++++++---------------- 1 file changed, 103 insertions(+), 126 deletions(-) diff --git a/src/python_testing/TC_ICDM_3_1.py b/src/python_testing/TC_ICDM_3_1.py index 938479a9147f5f..f20e2816723a28 100644 --- a/src/python_testing/TC_ICDM_3_1.py +++ b/src/python_testing/TC_ICDM_3_1.py @@ -72,32 +72,22 @@ def desc_TC_ICDM_3_1(self) -> str: def steps_TC_ICDM_3_1(self) -> list[TestStep]: steps = [ - TestStep("0a", "Commissioning, already done", + TestStep(0, "Commissioning, already done", is_commissioning=True), - TestStep( - "0b", "TH reads from the DUT the RegisteredClients attribute. RegisteredClients is empty."), - TestStep( - "1a", "TH reads from the DUT the ClientsSupportedPerFabric attribute."), - TestStep( - "1b", "TH reads from the DUT the ICDCounter attribute."), + TestStep("1a", "TH reads from the DUT the RegisteredClients attribute. RegisteredClients is empty."), + TestStep("1b", "TH reads from the DUT the ClientsSupportedPerFabric attribute."), + TestStep("1c", "TH reads from the DUT the ICDCounter attribute."), TestStep(2, "TH sends RegisterClient command."), TestStep(3, "TH reads from the DUT the RegisteredClients attribute."), - TestStep( - 4, "If len(RegisteredClients) is less than ClientsSupportedPerFabric, TH repeats RegisterClient command with different CheckInNodeID(s) until the number of entries in RegisteredClients equals ClientsSupportedPerFabric."), + TestStep(4, "If len(RegisteredClients) is less than ClientsSupportedPerFabric, TH repeats RegisterClient command with different CheckInNodeID(s) until the number of entries in RegisteredClients equals ClientsSupportedPerFabric."), TestStep(5, "TH reads from the DUT the RegisteredClients attribute."), - TestStep( - 6, "TH sends RegisterClient command with a different CheckInNodeID."), - TestStep( - 7, "TTH sends UnregisterClient command with the CheckInNodeID from Step 6."), - TestStep( - 8, "TH sends UnregisterClient command with the CheckInNodeID from Step 2."), - TestStep( - 9, "TH reads from the DUT the RegisteredClients attribute."), - TestStep( - 10, "Repeat Step 9 with the rest of CheckInNodeIDs from the list of RegisteredClients from Step 4, if any."), + TestStep(6, "TH sends RegisterClient command with a different CheckInNodeID."), + TestStep(7, "TTH sends UnregisterClient command with the CheckInNodeID from Step 6."), + TestStep(8, "TH sends UnregisterClient command with the CheckInNodeID from Step 2."), + TestStep(9, "TH reads from the DUT the RegisteredClients attribute."), + TestStep(10, "Repeat Step 9 with the rest of CheckInNodeIDs from the list of RegisteredClients from Step 4, if any."), TestStep(11, "TH reads from the DUT the RegisteredClients attribute."), - TestStep( - 12, "TH sends UnregisterClient command with the CheckInNodeID from Step 2."), + TestStep(12, "TH sends UnregisterClient command with the CheckInNodeID from Step 2."), ] return steps @@ -120,10 +110,10 @@ async def test_TC_ICDM_3_1(self): attributes = cluster.Attributes # Pre-Condition: Commissioning - self.step("0a") + self.step(0) - # Pre-Condition: Empty RegisteredClients attribute for all registrations - self.step("0b") + # Empty RegisteredClients attribute for all registrations + self.step("1a") registeredClients = await self._read_icdm_attribute_expect_success( attributes.RegisteredClients) @@ -135,56 +125,51 @@ async def test_TC_ICDM_3_1(self): e.status, Status.Success, "Unexpected error returned") pass - self.step("1a") - if self.pics_guard(self.check_pics("ICDM.S.A0005")): - clientsSupportedPerFabric = await self._read_icdm_attribute_expect_success( - attributes.ClientsSupportedPerFabric) - self.step("1b") - if self.pics_guard(self.check_pics("ICDM.S.A0005")): - icdCounter = await self._read_icdm_attribute_expect_success(attributes.ICDCounter) + clientsSupportedPerFabric = await self._read_icdm_attribute_expect_success( + attributes.ClientsSupportedPerFabric) + + self.step("1c") + icdCounter = await self._read_icdm_attribute_expect_success(attributes.ICDCounter) self.step(2) - if self.pics_guard(self.check_pics("ICDM.S.C00.Rsp")): - try: - response = await self._send_single_icdm_command(commands.RegisterClient(checkInNodeID=kStep2CheckInNodeId, monitoredSubject=kStep2MonitoredSubjectStep2, key=kStep2Key, clientType=clientTypeEnum.kEphemeral)) - except InteractionModelError as e: - asserts.assert_equal( - e.status, Status.Success, "Unexpected error returned") - pass + try: + response = await self._send_single_icdm_command(commands.RegisterClient(checkInNodeID=kStep2CheckInNodeId, monitoredSubject=kStep2MonitoredSubjectStep2, key=kStep2Key, clientType=clientTypeEnum.kEphemeral)) + except InteractionModelError as e: + asserts.assert_equal( + e.status, Status.Success, "Unexpected error returned") + pass - # Validate response contains the ICDCounter - asserts.assert_greater_equal(response.ICDCounter, icdCounter, - "The ICDCounter in the response does not match the read ICDCounter.") + # Validate response contains the ICDCounter + asserts.assert_greater_equal(response.ICDCounter, icdCounter, + "The ICDCounter in the response does not match the read ICDCounter.") self.step(3) - if self.pics_guard(self.check_pics("ICDM.S.A0003")): - registeredClients = await self._read_icdm_attribute_expect_success( - attributes.RegisteredClients) - # Validate list size - asserts.assert_equal(len(registeredClients), 1, - "The expected length of RegisteredClients is 1. List has the wrong size.") - - # Validate entry values - asserts.assert_equal( - registeredClients[0].checkInNodeID, kStep2CheckInNodeId, "The read attribute does not match the registered value.") - asserts.assert_equal( - registeredClients[0].monitoredSubject, kStep2MonitoredSubjectStep2, "The read attribute does not match the registered value.") - asserts.assert_equal( - registeredClients[0].clientType, clientTypeEnum.kEphemeral, "The read attribute does not match the registered value.") + registeredClients = await self._read_icdm_attribute_expect_success( + attributes.RegisteredClients) + # Validate list size + asserts.assert_equal(len(registeredClients), 1, + "The expected length of RegisteredClients is 1. List has the wrong size.") + + # Validate entry values + asserts.assert_equal( + registeredClients[0].checkInNodeID, kStep2CheckInNodeId, "The read attribute does not match the registered value.") + asserts.assert_equal( + registeredClients[0].monitoredSubject, kStep2MonitoredSubjectStep2, "The read attribute does not match the registered value.") + asserts.assert_equal( + registeredClients[0].clientType, clientTypeEnum.kEphemeral, "The read attribute does not match the registered value.") self.step(4) - if self.pics_guard(self.check_pics("ICDM.S.C00.Rsp")): - if (len(registeredClients) < clientsSupportedPerFabric): - newClients = [] - # Generate new clients data - for i in range(clientsSupportedPerFabric - len(registeredClients)): - newClients.append({ - "checkInNodeID": i + 1, - "monitoredSubject": i + 1, - "key": os.urandom(16), - "clientType": clientTypeEnum.kPermanent - }) + if (len(registeredClients) < clientsSupportedPerFabric): + newClients = [] + # Generate new clients data + for i in range(clientsSupportedPerFabric - len(registeredClients)): + newClients.append({ + "checkInNodeID": i + 1, + "monitoredSubject": i + 1, + "key": os.urandom(16), + "clientType": clientTypeEnum.kPermanent + }) for client in newClients: try: @@ -199,84 +184,76 @@ async def test_TC_ICDM_3_1(self): "The ICDCounter in the response does not match the read ICDCounter.") self.step(5) - if self.pics_guard(self.check_pics("ICDM.S.A0003")): - registeredClients = await self._read_icdm_attribute_expect_success( - attributes.RegisteredClients) + registeredClients = await self._read_icdm_attribute_expect_success( + attributes.RegisteredClients) - # Validate list size - asserts.assert_equal(len(registeredClients[1:]), len(newClients), - "The expected length of RegisteredClients is clientsSupportedPerFabric. List has the wrong size.") + # Validate list size + asserts.assert_equal(len(registeredClients[1:]), len(newClients), + "The expected length of RegisteredClients is clientsSupportedPerFabric. List has the wrong size.") - for client, expectedClient in zip(registeredClients[1:], newClients): - asserts.assert_equal( - client.checkInNodeID, expectedClient["checkInNodeID"], "The read attribute does not match the registered value.") - asserts.assert_equal( - client.monitoredSubject, expectedClient["monitoredSubject"], "The read attribute does not match the registered value.") - asserts.assert_equal( - client.clientType, expectedClient["clientType"], "The read attribute does not match the registered value.") + for client, expectedClient in zip(registeredClients[1:], newClients): + asserts.assert_equal( + client.checkInNodeID, expectedClient["checkInNodeID"], "The read attribute does not match the registered value.") + asserts.assert_equal( + client.monitoredSubject, expectedClient["monitoredSubject"], "The read attribute does not match the registered value.") + asserts.assert_equal( + client.clientType, expectedClient["clientType"], "The read attribute does not match the registered value.") self.step(6) - if self.pics_guard(self.check_pics("ICDM.S.C00.Rsp")): - try: - response = await self._send_single_icdm_command(commands.RegisterClient(checkInNodeID=0xFFFF, monitoredSubject=0xFFFF, key=os.urandom(16), clientType=clientTypeEnum.kPermanent)) - except InteractionModelError as e: - asserts.assert_equal( - e.status, Status.ResourceExhausted, "Unexpected error returned") - pass + try: + response = await self._send_single_icdm_command(commands.RegisterClient(checkInNodeID=0xFFFF, monitoredSubject=0xFFFF, key=os.urandom(16), clientType=clientTypeEnum.kPermanent)) + except InteractionModelError as e: + asserts.assert_equal( + e.status, Status.ResourceExhausted, "Unexpected error returned") + pass self.step(7) - if self.pics_guard(self.check_pics("ICDM.S.C02.Rsp")): - try: - await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=0xFFFF)) - except InteractionModelError as e: - asserts.assert_equal( - e.status, Status.NotFound, "Unexpected error returned") - pass + try: + await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=0xFFFF)) + except InteractionModelError as e: + asserts.assert_equal( + e.status, Status.NotFound, "Unexpected error returned") + pass self.step(8) - if self.pics_guard(self.check_pics("ICDM.S.C02.Rsp")): - try: - await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=kStep2CheckInNodeId)) - except InteractionModelError as e: - asserts.assert_equal( - e.status, Status.Success, "Unexpected error returned") - pass + try: + await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=kStep2CheckInNodeId)) + except InteractionModelError as e: + asserts.assert_equal( + e.status, Status.Success, "Unexpected error returned") + pass self.step(9) - if self.pics_guard(self.check_pics("ICDM.S.A0003")): - registeredClients = await self._read_icdm_attribute_expect_success( - attributes.RegisteredClients) + registeredClients = await self._read_icdm_attribute_expect_success( + attributes.RegisteredClients) - for client in registeredClients: - asserts.assert_not_equal(client.checkInNodeID, kStep2CheckInNodeId, - "CheckInNodeID was unregistered. It should not be present in the attribute list.") + for client in registeredClients: + asserts.assert_not_equal(client.checkInNodeID, kStep2CheckInNodeId, + "CheckInNodeID was unregistered. It should not be present in the attribute list.") self.step(10) - if self.pics_guard(self.check_pics("ICDM.S.C02.Rsp")): - for client in newClients: - try: - await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=client["checkInNodeID"])) - except InteractionModelError as e: - asserts.assert_equal( - e.status, Status.Success, "Unexpected error returned") - pass + for client in newClients: + try: + await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=client["checkInNodeID"])) + except InteractionModelError as e: + asserts.assert_equal( + e.status, Status.Success, "Unexpected error returned") + pass self.step(11) - if self.pics_guard(self.check_pics("ICDM.S.A0003")): - registeredClients = await self._read_icdm_attribute_expect_success( - attributes.RegisteredClients) + registeredClients = await self._read_icdm_attribute_expect_success( + attributes.RegisteredClients) - asserts.assert_true( - not registeredClients, "This list should empty. An element did not get deleted.") + asserts.assert_true( + not registeredClients, "This list should empty. An element did not get deleted.") self.step(12) - if self.pics_guard(self.check_pics("ICDM.S.C02.Rsp")): - try: - await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=kStep2CheckInNodeId)) - except InteractionModelError as e: - asserts.assert_equal( - e.status, Status.NotFound, "Unexpected error returned") - pass + try: + await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=kStep2CheckInNodeId)) + except InteractionModelError as e: + asserts.assert_equal( + e.status, Status.NotFound, "Unexpected error returned") + pass if __name__ == "__main__":