Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
swan-amazon committed Jan 15, 2025
1 parent b1508b1 commit c6ffded
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
11 changes: 10 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,14 @@
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8"
},
"autopep8.args": ["--max-line-length", "132"]
"autopep8.args": ["--max-line-length", "132"],
"python.autoComplete.extraPaths": [
"/workspace/connectedhomeip/src/controller/python"
],
"python.analysis.extraPaths": [
"/workspace/connectedhomeip/src/controller/python"
],
"python.analysis.include": [
"/workspace/connectedhomeip/src/controller/python"
]
}
37 changes: 22 additions & 15 deletions src/python_testing/TC_CGEN_2_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
# --qr-code MT:-24J0AFN00KA0648G00
# --trace-to json:log
# factoryreset: True
# quiet: True
# quiet: False
# === END CI TEST ARGUMENTS ===


import chip.clusters as Clusters
from chip import ChipDeviceCtrl
from chip.commissioning import ROOT_ENDPOINT_ID
from chip.clusters.Attribute import AsyncReadTransaction, ValueDecodeFailure
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
from mobly import asserts

Expand Down Expand Up @@ -68,9 +69,10 @@ async def test_TC_CGEN_2_5(self):

# Step 1: Begin commissioning with PASE and failsafe
self.step(1)
commissioner.SetTCRequired(False)
commissioner.SetSkipCommissioningComplete(True)
self.matter_test_config.commissioning_method = self.matter_test_config.in_test_commissioning_method
self.matter_test_config.tc_version_to_simulate = None
self.matter_test_config.tc_user_response_to_simulate = None
await self.commission_devices()

# Step 2: Read TCAcknowledgementsRequired
Expand All @@ -83,19 +85,24 @@ async def test_TC_CGEN_2_5(self):

# Step 3: Read TCUpdateDeadline
self.step(3)
response = await commissioner.ReadAttribute(
response: AsyncReadTransaction.ReadResponse.attributes = await commissioner.ReadAttribute(
nodeid=self.dut_node_id,
attributes=[(ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Attributes.TCUpdateDeadline)])
tcUpdateDeadline = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCUpdateDeadline]
asserts.assert_less(tcUpdateDeadline, 2**32, 'TCUpdateDeadline exceeds uint32 range')
tc_update_deadline = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCUpdateDeadline]

# Validate the value is of type Optional[uint32], e.g. either None or within the 32-bit range.
if isinstance(tc_update_deadline, ValueDecodeFailure):
asserts.assert_is_none(tc_update_deadline.TLVValue)
else:
asserts.assert_less(tc_update_deadline, 2**32, 'TCUpdateDeadline exceeds uint32 range')

# Step 4: Read FeatureMap
self.step(4)
response = await commissioner.ReadAttribute(
nodeid=self.dut_node_id,
attributes=[(ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Attributes.FeatureMap)])
featureMap = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.FeatureMap]
asserts.assert_equal(featureMap & 0x1, 0x1, 'TC feature flag not set')
feature_map = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.FeatureMap]
asserts.assert_equal(feature_map & 0x1, 0x1, 'TC feature flag not set')

# Step 5: Send SetTCAcknowledgements
self.step(5)
Expand Down Expand Up @@ -145,20 +152,20 @@ async def test_TC_CGEN_2_5(self):

# Step 9: Verify TCAcceptedVersion
self.step(9)
tcAcceptedVersion = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCAcceptedVersion]
asserts.assert_less(tcAcceptedVersion, 2**16, 'TCAcceptedVersion exceeds uint16 range')
asserts.assert_equal(tcAcceptedVersion, tc_version_to_simulate, 'Incorrect TCAcceptedVersion')
tc_accepted_version = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCAcceptedVersion]
asserts.assert_less(tc_accepted_version, 2**16, 'TCAcceptedVersion exceeds uint16 range')
asserts.assert_equal(tc_accepted_version, tc_version_to_simulate, 'Incorrect TCAcceptedVersion')

# Step 10: Verify TCAcknowledgements
self.step(10)
tcAcknowledgements = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCAcknowledgements]
asserts.assert_less(tcAcknowledgements, 2**16, 'TCAcknowledgements exceeds map16 range')
asserts.assert_equal(tcAcknowledgements, tc_user_response_to_simulate, 'Incorrect TCAcknowledgements')
tc_acknowledgements = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCAcknowledgements]
asserts.assert_less(tc_acknowledgements, 2**16, 'TCAcknowledgements exceeds map16 range')
asserts.assert_equal(tc_acknowledgements, tc_user_response_to_simulate, 'Incorrect TCAcknowledgements')

# Step 11: Verify TCMinRequiredVersion
self.step(11)
tcMinRequiredVersion = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCMinRequiredVersion]
asserts.assert_less(tcMinRequiredVersion, 2**16, 'TCMinRequiredVersion exceeds uint16 range')
tc_min_required_version = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCMinRequiredVersion]
asserts.assert_less(tc_min_required_version, 2**16, 'TCMinRequiredVersion exceeds uint16 range')

# Step 12: Verify TCAcknowledgementsRequired
self.step(12)
Expand Down

0 comments on commit c6ffded

Please sign in to comment.