From 9ee695b7320f438a59e1ab0e5ec0e49f4d98dfb6 Mon Sep 17 00:00:00 2001 From: sumaky Date: Wed, 18 Sep 2024 18:48:56 +0530 Subject: [PATCH] PR review -Init the pin and rid variables --- src/python_testing/TC_DRLK_2_9.py | 54 +++++++++++++++++-------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/src/python_testing/TC_DRLK_2_9.py b/src/python_testing/TC_DRLK_2_9.py index 231486506f7067..3f843f1d32ccdb 100644 --- a/src/python_testing/TC_DRLK_2_9.py +++ b/src/python_testing/TC_DRLK_2_9.py @@ -171,17 +171,18 @@ async def generate_max_pincode_len(self, maxPincodeLength): return ''.join(random.choices(string.digits, k=maxPincodeLength)) async def generate_code(self): - - validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) - self.pin_code = bytes(validpincodestr, 'ascii') - validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) - self.pin_code1 = bytes(validpincodestr, 'ascii') - validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) - self.pin_code2 = bytes(validpincodestr, 'ascii') - inavlidpincodestr = await self.generate_max_pincode_len(self.maxpincodelength+1) - self.inavlid_pincode = bytes(inavlidpincodestr, 'ascii') - validpincodestr = await self.generate_max_pincode_len(self.maxrfidcodelength) - self.rfid_tag = bytes(validpincodestr, 'ascii') + if (self.maxpincodelength != None): + validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) + self.pin_code = bytes(validpincodestr, 'ascii') + validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) + self.pin_code1 = bytes(validpincodestr, 'ascii') + validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) + self.pin_code2 = bytes(validpincodestr, 'ascii') + inavlidpincodestr = await self.generate_max_pincode_len(self.maxpincodelength+1) + self.inavlid_pincode = bytes(inavlidpincodestr, 'ascii') + if (self.maxrfidcodelength != None): + validpincodestr = await self.generate_max_pincode_len(self.maxrfidcodelength) + self.rfid_tag = bytes(validpincodestr, 'ascii') async def send_clear_user_cmd(self, user_index, expected_status: Status = Status.Success): try: @@ -259,8 +260,7 @@ async def set_credential_cmd(self, credential_enum: drlkcluster.Enums.Credential credentialType=credential_enum, credentialIndex=credentialIndex) try: - logging.info("maxpincodelength value is %s" % (self.maxpincodelength)) - logging.info("maxrfidcodelength value is %s" % (self.maxrfidcodelength)) + logging.info("Credential Data is %s" % (credentialData)) response = await self.send_single_cmd(cmd=drlkcluster.Commands.SetCredential( operationType=operationType, @@ -366,6 +366,11 @@ async def test_TC_DRLK_2_9(self): self.inavlid_pincode = b"" self.rfid_tag = b"" + self.minpincodelength = None + self.maxpincodelength = None + self.maxrfidcodelength = None + self.minrfidcodelength = None + self.endpoint = self.user_params.get("endpoint", 1) print("endpoint", self.endpoint) @@ -532,20 +537,21 @@ async def test_TC_DRLK_2_9(self): cluster=drlkcluster, attribute=Clusters.DoorLock.Attributes.FeatureMap) aliro_enabled = feature_map & Clusters.DoorLock.Bitmaps.Feature.kAliroProvisioning - if (aliro_enabled): credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroNonEvictableEndpointKey) - await self.clear_credentials_cmd(credential=credentials) - else: - try: - await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credentials), - endpoint=self.app_cluster_endpoint, - timedRequestTimeoutMs=1000) - asserts.fail("Unexpected success in sending ClearCredential Command with invalid CredentialTpe") + if (aliro_enabled): - except InteractionModelError as e: - asserts.assert_equal(e.status, Status.InvalidCommand, - "Unexpected error sending ClearCredential Command with invalid CredentialTpe") + await self.clear_credentials_cmd(credential=credentials) + else: + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credentials), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.fail("Unexpected success in sending ClearCredential Command with invalid CredentialTpe") + + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.InvalidCommand, + "Unexpected error sending ClearCredential Command with invalid CredentialTpe") self.step("14b") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")):