Skip to content

Commit 48bb705

Browse files
committed
Added generate_max_pincode_len for generating valid pin code of Max pincode length
1 parent 4eed013 commit 48bb705

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/python_testing/TC_DRLK_2_9.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
# === END CI TEST ARGUMENTS ===
2828

2929
import logging
30+
import random
31+
import string
3032

3133
import chip.clusters as Clusters
3234
from chip.clusters.Types import NullValue
@@ -35,6 +37,7 @@
3537
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches
3638
from mobly import asserts
3739

40+
3841
logger = logging.getLogger(__name__)
3942

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

171+
async def generate_max_pincode_len(self, maxPincodeLength):
172+
return ''.join(random.choices(string.digits, k=maxPincodeLength))
173+
168174
async def generate_code(self):
169175

170-
validpincodestr = await self.generate_pincode(self.maxpincodelength)
176+
validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength)
171177
self.pin_code = bytes(validpincodestr, 'ascii')
172-
validpincodestr = await self.generate_pincode(self.maxpincodelength)
178+
validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength)
173179
self.pin_code1 = bytes(validpincodestr, 'ascii')
174-
validpincodestr = await self.generate_pincode(self.maxpincodelength)
180+
validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength)
175181
self.pin_code2 = bytes(validpincodestr, 'ascii')
176-
inavlidpincodestr = await self.generate_pincode(self.maxpincodelength+1)
182+
inavlidpincodestr = await self.generate_max_pincode_len(self.maxpincodelength+1)
177183
self.inavlid_pincode = bytes(inavlidpincodestr, 'ascii')
178-
validpincodestr = await self.generate_pincode(self.maxrfidcodelength)
184+
validpincodestr = await self.generate_max_pincode_len(self.maxrfidcodelength)
179185
self.rfid_tag = bytes(validpincodestr, 'ascii')
180186

181187
async def send_clear_user_cmd(self, user_index, expected_status: Status = Status.Success):
@@ -595,7 +601,7 @@ async def test_TC_DRLK_2_9(self):
595601
start_credential_index = 1
596602
nextCredentialIndex = 1
597603
while 1:
598-
uniquePincodeString = await self.generate_pincode(self.maxpincodelength)
604+
uniquePincodeString = await self.generate_max_pincode_len(self.maxpincodelength)
599605
uniquePincode = bytes(uniquePincodeString, 'ascii')
600606
logging.info("Credential Data value is %s" % (uniquePincode))
601607
if start_credential_index <= (numberofcredentialsupportedperuser):

0 commit comments

Comments
 (0)