Skip to content

Commit 0495a4e

Browse files
authored
Python testing: Update commissioning window API (project-chip#36669)
* Python testing: Update commissioning window API - add some defaults to make this easier to use - change the name to match the other methods in the class * Fix API for new test
1 parent 4cf28ab commit 0495a4e

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

src/python_testing/TC_ACE_1_5.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async def test_TC_ACE_1_5(self):
7171
self.th2 = new_fabric_admin.NewController(nodeId=TH2_nodeid,
7272
paaTrustStorePath=str(self.matter_test_config.paa_trust_store_path))
7373

74-
params = await self.openCommissioningWindow(self.th1, self.dut_node_id)
74+
params = await self.open_commissioning_window(self.th1, self.dut_node_id)
7575
self.print_step(2, "TH1 opens the commissioning window on the DUT")
7676

7777
await self.th2.CommissionOnNetwork(

src/python_testing/TC_BRBINFO_4_1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ async def setup_class(self):
189189
filter=self.th_icd_server_discriminator)
190190

191191
logging.info("Commissioning of ICD to fabric two (DUT)")
192-
params = await self.openCommissioningWindow(dev_ctrl=self.default_controller, node_id=self.icd_nodeid)
192+
params = await self.open_commissioning_window(dev_ctrl=self.default_controller, node_id=self.icd_nodeid)
193193

194194
if not self.is_pics_sdk_ci_only:
195195
self._ask_for_vendor_commissioning_ux_operation(

src/python_testing/TC_CADMIN_1_19.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ async def test_TC_CADMIN_1_19(self):
111111
self.current_step_index = 4
112112

113113
self.step("4a")
114-
params = await self.openCommissioningWindow(dev_ctrl=self.th1, timeout=self.max_window_duration, node_id=self.dut_node_id)
114+
params = await self.open_commissioning_window(dev_ctrl=self.th1, timeout=self.max_window_duration, node_id=self.dut_node_id)
115115

116116
self.step("4b")
117117
fids_ca_dir[fid] = self.certificate_authority_manager.NewCertificateAuthority()
@@ -128,7 +128,7 @@ async def test_TC_CADMIN_1_19(self):
128128
asserts.assert_equal(current_fabrics, max_fabrics, "Expected number of fabrics not correct")
129129

130130
self.step(6)
131-
params = await self.openCommissioningWindow(dev_ctrl=self.th1, node_id=self.dut_node_id)
131+
params = await self.open_commissioning_window(dev_ctrl=self.th1, node_id=self.dut_node_id)
132132

133133
self.step(7)
134134
# TH creates a controller on a new fabric and attempts to commission DUT_CE using that controller

src/python_testing/TC_CCTRL_2_2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ async def test_TC_CCTRL_2_2(self):
170170
asserts.assert_equal(e.status, Status.Failure, "Incorrect error returned")
171171

172172
self.step(6)
173-
params = await self.openCommissioningWindow(dev_ctrl=self.default_controller, node_id=self.dut_node_id)
173+
params = await self.open_commissioning_window(dev_ctrl=self.default_controller, node_id=self.dut_node_id)
174174
self.step(7)
175175
pase_nodeid = self.dut_node_id + 1
176176
await self.default_controller.FindOrEstablishPASESession(setupCode=params.commissioningParameters.setupQRCode, nodeid=pase_nodeid)

src/python_testing/TC_OPCREDS_3_4.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ async def test_TC_OPCREDS_3_4(self):
273273
"Failure status returned from arm failsafe")
274274

275275
self.step(22)
276-
resp = await self.openCommissioningWindow(self.default_controller, self.dut_node_id)
276+
resp = await self.open_commissioning_window()
277277

278278
self.step(23)
279279
await self.default_controller.FindOrEstablishPASESession(setupCode=resp.commissioningParameters.setupQRCode, nodeid=self.dut_node_id)

src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1141,8 +1141,12 @@ def check_pics(self, pics_key: str) -> bool:
11411141
def is_pics_sdk_ci_only(self) -> bool:
11421142
return self.check_pics('PICS_SDK_CI_ONLY')
11431143

1144-
async def openCommissioningWindow(self, dev_ctrl: ChipDeviceCtrl, node_id: int, timeout: int = 900) -> CustomCommissioningParameters:
1144+
async def open_commissioning_window(self, dev_ctrl: Optional[ChipDeviceCtrl] = None, node_id: Optional[int] = None, timeout: int = 900) -> CustomCommissioningParameters:
11451145
rnd_discriminator = random.randint(0, 4095)
1146+
if dev_ctrl is None:
1147+
dev_ctrl = self.default_controller
1148+
if node_id is None:
1149+
node_id = self.dut_node_id
11461150
try:
11471151
commissioning_params = await dev_ctrl.OpenCommissioningWindow(nodeid=node_id, timeout=timeout, iteration=1000,
11481152
discriminator=rnd_discriminator, option=1)
@@ -1166,7 +1170,6 @@ async def read_single_attribute_check_success(
11661170
if node_id is None:
11671171
node_id = self.dut_node_id
11681172
if endpoint is None:
1169-
#endpoint = 0 if self.matter_test_config.endpoint is None else self.matter_test_config.endpoint
11701173
endpoint = self.get_endpoint()
11711174

11721175
result = await dev_ctrl.ReadAttribute(node_id, [(endpoint, attribute)], fabricFiltered=fabric_filtered)
@@ -1199,7 +1202,6 @@ async def read_single_attribute_expect_error(
11991202
if node_id is None:
12001203
node_id = self.dut_node_id
12011204
if endpoint is None:
1202-
#endpoint = 0 if self.matter_test_config.endpoint is None else self.matter_test_config.endpoint
12031205
endpoint = self.get_endpoint()
12041206

12051207
result = await dev_ctrl.ReadAttribute(node_id, [(endpoint, attribute)], fabricFiltered=fabric_filtered)
@@ -1248,7 +1250,6 @@ async def send_single_cmd(
12481250
if node_id is None:
12491251
node_id = self.dut_node_id
12501252
if endpoint is None:
1251-
#endpoint = 0 if self.matter_test_config.endpoint is None else self.matter_test_config.endpoint
12521253
endpoint = self.get_endpoint()
12531254

12541255
result = await dev_ctrl.SendCommand(nodeid=node_id, endpoint=endpoint, payload=cmd, timedRequestTimeoutMs=timedRequestTimeoutMs,
@@ -1842,7 +1843,6 @@ def convert_args_to_matter_config(args: argparse.Namespace) -> MatterTestConfig:
18421843
config.pics = {} if args.PICS is None else read_pics_from_file(args.PICS)
18431844
config.tests = [] if args.tests is None else args.tests
18441845
config.timeout = args.timeout # This can be none, we pull the default from the test if it's unspecified
1845-
#config.endpoint = args.endpoint
18461846
config.endpoint = args.endpoint # This can be None, the get_endpoint function allows the tests to supply a default
18471847
config.app_pid = 0 if args.app_pid is None else args.app_pid
18481848

0 commit comments

Comments
 (0)