Skip to content

Commit

Permalink
Updating TC_CADMIN_1_22 and TC_CADMIN_1_24:
Browse files Browse the repository at this point in the history
- Resolved linting issues
  • Loading branch information
j-ororke committed Sep 17, 2024
1 parent e244d98 commit c8a2509
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions src/python_testing/TC_CADMIN_1_22.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,21 @@ async def CommissionAttempt(
self, setupPinCode: int, thnum: int, th: str, fail: bool):

logging.info(f"-----------------Commissioning with TH_CR{str(thnum)}-------------------------")
if fail == True:
if fail:
ctx = asserts.assert_raises(ChipStackError)
self.print_step(0, ctx)
with ctx:
await th.CommissionOnNetwork(
nodeId=self.dut_node_id, setupPinCode=setup_code,
nodeId=self.dut_node_id, setupPinCode=setupPinCode,
filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator)
errcode = PyChipError.from_code(ctx.exception.err)
logging.info('Commissioning complete done. Successful? {}, errorcode = {}, cycle={}'.format(
errcode.is_success, errcode, (cycle+1)))
logging.info('Commissioning complete done. Successful? {}, errorcode = {}'.format(
errcode.is_success, errcode))
asserts.assert_false(errcode.is_success, 'Commissioning complete did not error as expected')
asserts.assert_true(errcode.sdk_code == 0x0000000B,
'Unexpected error code returned from CommissioningComplete')

elif fail == False:
elif not fail:
await th.CommissionOnNetwork(
nodeId=self.dut_node_id, setupPinCode=setupPinCode,
filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator)
Expand Down Expand Up @@ -105,7 +105,7 @@ async def test_TC_CADMIN_1_22(self):
self.discriminator = random.randint(0, 4095)

self.step(2)
params = await self.th1.OpenCommissioningWindow(
await self.th1.OpenCommissioningWindow(
nodeid=self.dut_node_id, timeout=900, iteration=10000, discriminator=self.discriminator, option=1)

self.step(3)
Expand All @@ -117,11 +117,11 @@ async def test_TC_CADMIN_1_22(self):
self.step(4)
window_status = await self.get_window_status()
if window_status != 0:
asserts.fail(f"Commissioning window is expected to be closed, but was found to be open")
asserts.fail("Commissioning window is expected to be closed, but was found to be open")

self.step(5)
try:
params = await self.th1.OpenCommissioningWindow(
await self.th1.OpenCommissioningWindow(
nodeid=self.dut_node_id, timeout=901, iteration=10000, discriminator=self.discriminator, option=1)

except ChipStackError as e:
Expand All @@ -133,7 +133,7 @@ async def test_TC_CADMIN_1_22(self):
self.step(6)
window_status2 = await self.get_window_status()
if window_status2 != 0:
asserts.fail(f"Commissioning window is expected to be closed, but was found to be open")
asserts.fail("Commissioning window is expected to be closed, but was found to be open")


if __name__ == "__main__":
Expand Down
18 changes: 9 additions & 9 deletions src/python_testing/TC_CADMIN_1_24.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,21 @@ async def CommissionAttempt(
self, setupPinCode: int, thnum: int, th: str, fail: bool):

logging.info(f"-----------------Commissioning with TH_CR{str(thnum)}-------------------------")
if fail == True:
if fail:
ctx = asserts.assert_raises(ChipStackError)
self.print_step(0, ctx)
with ctx:
await th.CommissionOnNetwork(
nodeId=self.dut_node_id, setupPinCode=setup_code,
nodeId=self.dut_node_id, setupPinCode=setupPinCode,
filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator)
errcode = PyChipError.from_code(ctx.exception.err)
logging.info('Commissioning complete done. Successful? {}, errorcode = {}, cycle={}'.format(
errcode.is_success, errcode, (cycle+1)))
logging.info('Commissioning complete done. Successful? {}, errorcode = {}'.format(
errcode.is_success, errcode))
asserts.assert_false(errcode.is_success, 'Commissioning complete did not error as expected')
asserts.assert_true(errcode.sdk_code == 0x0000000B,
'Unexpected error code returned from CommissioningComplete')

elif fail == False:
elif not fail:
await th.CommissionOnNetwork(
nodeId=self.dut_node_id, setupPinCode=setupPinCode,
filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator)
Expand Down Expand Up @@ -105,7 +105,7 @@ async def test_TC_CADMIN_1_24(self):
self.discriminator = random.randint(0, 4095)

self.step(2)
params = await self.th1.OpenCommissioningWindow(
await self.th1.OpenCommissioningWindow(
nodeid=self.dut_node_id, timeout=180, iteration=10000, discriminator=self.discriminator, option=1)

self.step(3)
Expand All @@ -117,11 +117,11 @@ async def test_TC_CADMIN_1_24(self):
self.step(4)
window_status = await self.get_window_status()
if window_status != 0:
asserts.fail(f"Commissioning window is expected to be closed, but was found to be open")
asserts.fail("Commissioning window is expected to be closed, but was found to be open")

self.step(5)
try:
params = await self.th1.OpenCommissioningWindow(
await self.th1.OpenCommissioningWindow(
nodeid=self.dut_node_id, timeout=179, iteration=10000, discriminator=self.discriminator, option=1)

except ChipStackError as e:
Expand All @@ -133,7 +133,7 @@ async def test_TC_CADMIN_1_24(self):
self.step(6)
window_status2 = await self.get_window_status()
if window_status2 != 0:
asserts.fail(f"Commissioning window is expected to be closed, but was found to be open")
asserts.fail("Commissioning window is expected to be closed, but was found to be open")


if __name__ == "__main__":
Expand Down

0 comments on commit c8a2509

Please sign in to comment.