Skip to content

Commit

Permalink
Added generate_max_pincode_len for generating valid pin code of Max p…
Browse files Browse the repository at this point in the history
…incode length
  • Loading branch information
sumaky committed Sep 17, 2024
1 parent 4eed013 commit 48bb705
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/python_testing/TC_DRLK_2_9.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
# === END CI TEST ARGUMENTS ===

import logging
import random
import string

import chip.clusters as Clusters
from chip.clusters.Types import NullValue
Expand All @@ -35,6 +37,7 @@
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches
from mobly import asserts


logger = logging.getLogger(__name__)

drlkcluster = Clusters.DoorLock
Expand Down Expand Up @@ -165,17 +168,20 @@ async def read_attributes_from_dut(self, endpoint, cluster, attribute, expected_
def pics_TC_DRLK_2_9(self) -> list[str]:
return ["DRLK.S"]

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_pincode(self.maxpincodelength)
validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength)
self.pin_code = bytes(validpincodestr, 'ascii')
validpincodestr = await self.generate_pincode(self.maxpincodelength)
validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength)
self.pin_code1 = bytes(validpincodestr, 'ascii')
validpincodestr = await self.generate_pincode(self.maxpincodelength)
validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength)
self.pin_code2 = bytes(validpincodestr, 'ascii')
inavlidpincodestr = await self.generate_pincode(self.maxpincodelength+1)
inavlidpincodestr = await self.generate_max_pincode_len(self.maxpincodelength+1)
self.inavlid_pincode = bytes(inavlidpincodestr, 'ascii')
validpincodestr = await self.generate_pincode(self.maxrfidcodelength)
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):
Expand Down Expand Up @@ -595,7 +601,7 @@ async def test_TC_DRLK_2_9(self):
start_credential_index = 1
nextCredentialIndex = 1
while 1:
uniquePincodeString = await self.generate_pincode(self.maxpincodelength)
uniquePincodeString = await self.generate_max_pincode_len(self.maxpincodelength)
uniquePincode = bytes(uniquePincodeString, 'ascii')
logging.info("Credential Data value is %s" % (uniquePincode))
if start_credential_index <= (numberofcredentialsupportedperuser):
Expand Down

0 comments on commit 48bb705

Please sign in to comment.