Skip to content

Commit

Permalink
Fix some tests using removed class member
Browse files Browse the repository at this point in the history
  • Loading branch information
cecille committed Aug 16, 2024
1 parent 490f27b commit bcdabaa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/controller/python/chip/native/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def raise_on_error(self) -> None:
if exception is not None: # Ensure exception is not None to avoid mypy error and only raise valid exceptions
raise exception

@classmethod
def from_code(cls, code):
return cls(code=code, line=0, file=ctypes.c_void_p())

@property
def is_success(self) -> bool:
return self.code == 0
Expand Down
3 changes: 2 additions & 1 deletion src/python_testing/TC_CADMIN_1_9.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from chip import ChipDeviceCtrl
from chip.ChipDeviceCtrl import CommissioningParameters
from chip.exceptions import ChipStackError
from chip.native import PyChipError
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
from mobly import asserts

Expand Down Expand Up @@ -74,7 +75,7 @@ async def CommissionOnNetwork(
await self.th2.CommissionOnNetwork(
nodeId=self.dut_node_id, setupPinCode=setup_code,
filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator)
errcode = ctx.exception.chip_error
errcode = PyChipError.from_code(ctx.exception.err)
return errcode

async def CommissionAttempt(
Expand Down
3 changes: 2 additions & 1 deletion src/python_testing/TC_CGEN_2_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from chip import ChipDeviceCtrl
from chip.ChipDeviceCtrl import CommissioningParameters
from chip.exceptions import ChipStackError
from chip.native import PyChipError
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main
from mobly import asserts

Expand Down Expand Up @@ -78,7 +79,7 @@ async def CommissionToStageSendCompleteAndCleanup(
await self.th2.CommissionOnNetwork(
nodeId=self.dut_node_id, setupPinCode=params.setupPinCode,
filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator)
errcode = ctx.exception.chip_error
errcode = PyChipError.from_code(ctx.exception.err)
asserts.assert_true(errcode.sdk_part == expectedErrorPart, 'Unexpected error type returned from CommissioningComplete')
asserts.assert_true(errcode.sdk_code == expectedErrCode, 'Unexpected error code returned from CommissioningComplete')
revokeCmd = Clusters.AdministratorCommissioning.Commands.RevokeCommissioning()
Expand Down

0 comments on commit bcdabaa

Please sign in to comment.