Skip to content

Commit 6931d02

Browse files
committed
restyled
1 parent 91dd73f commit 6931d02

File tree

1 file changed

+39
-19
lines changed

1 file changed

+39
-19
lines changed

src/python_testing/TC_CADMIN_1_3_4.py

+39-19
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@ async def get_txt_record(self):
7777

7878
async def write_nl_attr(self, th: ChipDeviceCtrl, attr_val: object):
7979
result = await th.WriteAttribute(nodeid=self.dut_node_id, attributes=[(0, attr_val)])
80-
asserts.assert_equal(result[0].Status, Status.Success, f"{th} node label write failed")
80+
asserts.assert_equal(
81+
result[0].Status, Status.Success, f"{th} node label write failed")
8182

8283
async def read_nl_attr(self, th: ChipDeviceCtrl, attr_val: object):
8384
try:
8485
await th.ReadAttribute(nodeid=self.dut_node_id, attributes=[(0, attr_val)])
8586
except Exception as e:
86-
asserts.assert_equal(e.err, "Received error message from read attribute attempt")
87+
asserts.assert_equal(
88+
e.err, "Received error message from read attribute attempt")
8789
self.print_step(0, e)
8890

8991
async def read_currentfabricindex(self, th: ChipDeviceCtrl) -> int:
@@ -124,7 +126,8 @@ async def combined_commission_val_steps(self, commission_type: str):
124126
)
125127

126128
elif commission_type == "BCM":
127-
obcCmd = Clusters.AdministratorCommissioning.Commands.OpenBasicCommissioningWindow(180)
129+
obcCmd = Clusters.AdministratorCommissioning.Commands.OpenBasicCommissioningWindow(
130+
180)
128131
await self.th1.SendCommand(nodeid=self.dut_node_id, endpoint=0, payload=obcCmd, timedRequestTimeoutMs=6000)
129132

130133
else:
@@ -134,7 +137,8 @@ async def combined_commission_val_steps(self, commission_type: str):
134137
services = await self.get_txt_record()
135138
expected_cm_value = "2" if commission_type == "ECM" else "1"
136139
if services.txt_record['CM'] != expected_cm_value:
137-
asserts.fail(f"Expected cm record value {expected_cm_value}, but found {services.txt_record['CM']}")
140+
asserts.fail(
141+
f"Expected cm record value {expected_cm_value}, but found {services.txt_record['CM']}")
138142

139143
self.step("3c")
140144
BI_cluster = Clusters.BasicInformation
@@ -145,8 +149,10 @@ async def combined_commission_val_steps(self, commission_type: str):
145149
self.step(4)
146150
# Establishing TH2
147151
th2_certificate_authority = self.certificate_authority_manager.NewCertificateAuthority()
148-
th2_fabric_admin = th2_certificate_authority.NewFabricAdmin(vendorId=0xFFF1, fabricId=self.th1.fabricId + 1)
149-
self.th2 = th2_fabric_admin.NewController(nodeId=2, useTestCommissioner=True)
152+
th2_fabric_admin = th2_certificate_authority.NewFabricAdmin(
153+
vendorId=0xFFF1, fabricId=self.th1.fabricId + 1)
154+
self.th2 = th2_fabric_admin.NewController(
155+
nodeId=2, useTestCommissioner=True)
150156

151157
if commission_type == "ECM":
152158
await self.th2.CommissionOnNetwork(
@@ -158,7 +164,8 @@ async def combined_commission_val_steps(self, commission_type: str):
158164
else:
159165
setupPayloadInfo = self.get_setup_payload_info()
160166
if not setupPayloadInfo:
161-
asserts.fail("Setup payload info is required for basic commissioning.")
167+
asserts.fail(
168+
"Setup payload info is required for basic commissioning.")
162169
await self.th2.CommissionOnNetwork(
163170
nodeId=self.dut_node_id,
164171
setupPinCode=setupPayloadInfo[0].passcode,
@@ -174,17 +181,21 @@ async def combined_commission_val_steps(self, commission_type: str):
174181
th1_cam_rcac = TLVReader(base64.b64decode(
175182
self.certificate_authority_manager.activeCaList[0]._persistentStorage._jsonData["sdk-config"]["f/1/r"])).get()["Any"][9]
176183
if th1_fabric_info[0].rootPublicKey != th1_cam_rcac:
177-
asserts.fail("Public keys from fabric and certs for TH1 are not the same.")
184+
asserts.fail(
185+
"Public keys from fabric and certs for TH1 are not the same.")
178186
if th1_fabric_info[0].nodeID != self.dut_node_id:
179-
asserts.fail("DUT node ID from fabric does not equal DUT node ID for TH1 during commissioning.")
187+
asserts.fail(
188+
"DUT node ID from fabric does not equal DUT node ID for TH1 during commissioning.")
180189

181190
self.step(6)
182191
# TH_CR2 reads the Fabrics attribute
183192
th2_fabric_info = await self.get_fabrics(th=self.th2)
184193
if th2_fabric_info[0].rootPublicKey != th2_rcac_decoded:
185-
asserts.fail("Public keys from fabric and certs for TH2 are not the same.")
194+
asserts.fail(
195+
"Public keys from fabric and certs for TH2 are not the same.")
186196
if th2_fabric_info[0].nodeID != self.dut_node_id:
187-
asserts.fail("DUT node ID from fabric does not equal DUT node ID for TH2 during commissioning.")
197+
asserts.fail(
198+
"DUT node ID from fabric does not equal DUT node ID for TH2 during commissioning.")
188199

189200
if commission_type == "ECM":
190201
self.step(7)
@@ -195,7 +206,8 @@ async def combined_commission_val_steps(self, commission_type: str):
195206
self.step(8)
196207
# TH_CR2 writes and reads the Basic Information Cluster’s NodeLabel mandatory attribute of DUT_CE
197208
val = await self.read_nl_attr(th=self.th2, attr_val=self.nl_attribute)
198-
self.print_step("basic information cluster node label attr value", val)
209+
self.print_step(
210+
"basic information cluster node label attr value", val)
199211
await self.write_nl_attr(th=self.th2, attr_val=self.nl_attribute)
200212
await self.read_nl_attr(th=self.th2, attr_val=self.nl_attribute)
201213

@@ -219,7 +231,8 @@ async def combined_commission_val_steps(self, commission_type: str):
219231
outer_key = list(window_status.keys())[0]
220232
inner_key = list(window_status[outer_key].keys())[1]
221233
if window_status[outer_key][inner_key] != Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen:
222-
asserts.fail("Commissioning window is expected to be closed, but was found to be open")
234+
asserts.fail(
235+
"Commissioning window is expected to be closed, but was found to be open")
223236

224237
self.step(12)
225238
# TH_CR2 opens a commissioning window on DUT_CE using ECM
@@ -258,19 +271,22 @@ async def combined_commission_val_steps(self, commission_type: str):
258271
outer_key = list(th2_idx.keys())[0]
259272
inner_key = list(th2_idx[outer_key].keys())[0]
260273
attribute_key = list(th2_idx[outer_key][inner_key].keys())[1]
261-
removeFabricCmd = Clusters.OperationalCredentials.Commands.RemoveFabric(th2_idx[outer_key][inner_key][attribute_key])
274+
removeFabricCmd = Clusters.OperationalCredentials.Commands.RemoveFabric(
275+
th2_idx[outer_key][inner_key][attribute_key])
262276
await self.th1.SendCommand(nodeid=self.dut_node_id, endpoint=0, payload=removeFabricCmd)
263277

264278
def pics_TC_CADMIN_1_3(self) -> list[str]:
265279
return ["CADMIN.S"]
266280

267281
def steps_TC_CADMIN_1_3(self) -> list[TestStep]:
268282
return [
269-
TestStep(1, "TH_CR1 starts a commissioning process with DUT_CE", is_commissioning=True),
283+
TestStep(
284+
1, "TH_CR1 starts a commissioning process with DUT_CE", is_commissioning=True),
270285
TestStep(2, "TH_CR1 reads the BasicCommissioningInfo attribute from the General Commissioning cluster and saves the MaxCumulativeFailsafeSeconds field as max_window_duration."),
271286
TestStep("3a", "TH_CR1 opens a commissioning window on DUT_CE using a commissioning timeout of max_window_duration using ECM",
272287
"DUT_CE opens its Commissioning window to allow a second commissioning."),
273-
TestStep("3b", "DNS-SD records shows DUT_CE advertising", "Verify that the DNS-SD advertisement shows CM=2"),
288+
TestStep("3b", "DNS-SD records shows DUT_CE advertising",
289+
"Verify that the DNS-SD advertisement shows CM=2"),
274290
TestStep("3c", "TH_CR1 writes and reads the Basic Information Cluster’s NodeLabel mandatory attribute of DUT_CE",
275291
"Verify DUT_CE responds to both write/read with a success"),
276292
TestStep(4, "TH creates a controller (TH_CR2) on a new fabric and commissions DUT_CE using that controller. TH_CR2 should commission the device using a different NodeID than TH_CR1.",
@@ -283,7 +299,8 @@ def steps_TC_CADMIN_1_3(self) -> list[TestStep]:
283299
"Verify DUT_CE responds to both write/read with a success"),
284300
TestStep(8, "TH_CR2 reads, writes and then reads the Basic Information Cluster’s NodeLabel mandatory attribute of DUT_CE",
285301
"Verify the initial read reflect the value written in the above step. Verify DUT_CE responds to both write/read with a success"),
286-
TestStep(9, "TH_CR2 opens a commissioning window on DUT_CE for 180 seconds using ECM"),
302+
TestStep(
303+
9, "TH_CR2 opens a commissioning window on DUT_CE for 180 seconds using ECM"),
287304
TestStep(10, "Wait for the commissioning window in step 9 to timeout"),
288305
TestStep(11, "TH_CR2 reads the window status to verify the DUT_CE window is closed",
289306
"DUT_CE windows status shows the window is closed"),
@@ -300,11 +317,13 @@ def pics_TC_CADMIN_1_4(self) -> list[str]:
300317

301318
def steps_TC_CADMIN_1_4(self) -> list[TestStep]:
302319
return [
303-
TestStep(1, "TH_CR1 starts a commissioning process with DUT_CE", is_commissioning=True),
320+
TestStep(
321+
1, "TH_CR1 starts a commissioning process with DUT_CE", is_commissioning=True),
304322
TestStep(2, "TH_CR1 reads the BasicCommissioningInfo attribute from the General Commissioning cluster and saves the MaxCumulativeFailsafeSeconds field as max_window_duration."),
305323
TestStep("3a", "TH_CR1 opens a commissioning window on DUT_CE using a commissioning timeout of max_window_duration using BCM",
306324
"DUT_CE opens its Commissioning window to allow a second commissioning."),
307-
TestStep("3b", "DNS-SD records shows DUT_CE advertising", "Verify that the DNS-SD advertisement shows CM=1"),
325+
TestStep("3b", "DNS-SD records shows DUT_CE advertising",
326+
"Verify that the DNS-SD advertisement shows CM=1"),
308327
TestStep("3c", "TH_CR1 writes and reads the Basic Information Cluster’s NodeLabel mandatory attribute of DUT_CE",
309328
"Verify DUT_CE responds to both write/read with a success"),
310329
TestStep(4, "TH creates a controller (TH_CR2) on a new fabric and commissions DUT_CE using that controller. TH_CR2 should commission the device using a different NodeID than TH_CR1.",
@@ -325,6 +344,7 @@ async def test_TC_CADMIN_1_3(self):
325344
async def test_TC_CADMIN_1_4(self):
326345
await self.combined_commission_val_steps(commission_type="BCM")
327346

347+
328348
global __test_class__
329349
__test_class__ = TC_CADMIN
330350

0 commit comments

Comments
 (0)