Skip to content

Commit c6ffded

Browse files
committed
wip
1 parent b1508b1 commit c6ffded

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

.vscode/settings.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -198,5 +198,14 @@
198198
"[python]": {
199199
"editor.defaultFormatter": "ms-python.autopep8"
200200
},
201-
"autopep8.args": ["--max-line-length", "132"]
201+
"autopep8.args": ["--max-line-length", "132"],
202+
"python.autoComplete.extraPaths": [
203+
"/workspace/connectedhomeip/src/controller/python"
204+
],
205+
"python.analysis.extraPaths": [
206+
"/workspace/connectedhomeip/src/controller/python"
207+
],
208+
"python.analysis.include": [
209+
"/workspace/connectedhomeip/src/controller/python"
210+
]
202211
}

src/python_testing/TC_CGEN_2_5.py

+22-15
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@
3232
# --qr-code MT:-24J0AFN00KA0648G00
3333
# --trace-to json:log
3434
# factoryreset: True
35-
# quiet: True
35+
# quiet: False
3636
# === END CI TEST ARGUMENTS ===
3737

3838

3939
import chip.clusters as Clusters
4040
from chip import ChipDeviceCtrl
4141
from chip.commissioning import ROOT_ENDPOINT_ID
42+
from chip.clusters.Attribute import AsyncReadTransaction, ValueDecodeFailure
4243
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
4344
from mobly import asserts
4445

@@ -68,9 +69,10 @@ async def test_TC_CGEN_2_5(self):
6869

6970
# Step 1: Begin commissioning with PASE and failsafe
7071
self.step(1)
71-
commissioner.SetTCRequired(False)
7272
commissioner.SetSkipCommissioningComplete(True)
7373
self.matter_test_config.commissioning_method = self.matter_test_config.in_test_commissioning_method
74+
self.matter_test_config.tc_version_to_simulate = None
75+
self.matter_test_config.tc_user_response_to_simulate = None
7476
await self.commission_devices()
7577

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

8486
# Step 3: Read TCUpdateDeadline
8587
self.step(3)
86-
response = await commissioner.ReadAttribute(
88+
response: AsyncReadTransaction.ReadResponse.attributes = await commissioner.ReadAttribute(
8789
nodeid=self.dut_node_id,
8890
attributes=[(ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Attributes.TCUpdateDeadline)])
89-
tcUpdateDeadline = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCUpdateDeadline]
90-
asserts.assert_less(tcUpdateDeadline, 2**32, 'TCUpdateDeadline exceeds uint32 range')
91+
tc_update_deadline = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCUpdateDeadline]
92+
93+
# Validate the value is of type Optional[uint32], e.g. either None or within the 32-bit range.
94+
if isinstance(tc_update_deadline, ValueDecodeFailure):
95+
asserts.assert_is_none(tc_update_deadline.TLVValue)
96+
else:
97+
asserts.assert_less(tc_update_deadline, 2**32, 'TCUpdateDeadline exceeds uint32 range')
9198

9299
# Step 4: Read FeatureMap
93100
self.step(4)
94101
response = await commissioner.ReadAttribute(
95102
nodeid=self.dut_node_id,
96103
attributes=[(ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Attributes.FeatureMap)])
97-
featureMap = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.FeatureMap]
98-
asserts.assert_equal(featureMap & 0x1, 0x1, 'TC feature flag not set')
104+
feature_map = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.FeatureMap]
105+
asserts.assert_equal(feature_map & 0x1, 0x1, 'TC feature flag not set')
99106

100107
# Step 5: Send SetTCAcknowledgements
101108
self.step(5)
@@ -145,20 +152,20 @@ async def test_TC_CGEN_2_5(self):
145152

146153
# Step 9: Verify TCAcceptedVersion
147154
self.step(9)
148-
tcAcceptedVersion = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCAcceptedVersion]
149-
asserts.assert_less(tcAcceptedVersion, 2**16, 'TCAcceptedVersion exceeds uint16 range')
150-
asserts.assert_equal(tcAcceptedVersion, tc_version_to_simulate, 'Incorrect TCAcceptedVersion')
155+
tc_accepted_version = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCAcceptedVersion]
156+
asserts.assert_less(tc_accepted_version, 2**16, 'TCAcceptedVersion exceeds uint16 range')
157+
asserts.assert_equal(tc_accepted_version, tc_version_to_simulate, 'Incorrect TCAcceptedVersion')
151158

152159
# Step 10: Verify TCAcknowledgements
153160
self.step(10)
154-
tcAcknowledgements = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCAcknowledgements]
155-
asserts.assert_less(tcAcknowledgements, 2**16, 'TCAcknowledgements exceeds map16 range')
156-
asserts.assert_equal(tcAcknowledgements, tc_user_response_to_simulate, 'Incorrect TCAcknowledgements')
161+
tc_acknowledgements = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCAcknowledgements]
162+
asserts.assert_less(tc_acknowledgements, 2**16, 'TCAcknowledgements exceeds map16 range')
163+
asserts.assert_equal(tc_acknowledgements, tc_user_response_to_simulate, 'Incorrect TCAcknowledgements')
157164

158165
# Step 11: Verify TCMinRequiredVersion
159166
self.step(11)
160-
tcMinRequiredVersion = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCMinRequiredVersion]
161-
asserts.assert_less(tcMinRequiredVersion, 2**16, 'TCMinRequiredVersion exceeds uint16 range')
167+
tc_min_required_version = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCMinRequiredVersion]
168+
asserts.assert_less(tc_min_required_version, 2**16, 'TCMinRequiredVersion exceeds uint16 range')
162169

163170
# Step 12: Verify TCAcknowledgementsRequired
164171
self.step(12)

0 commit comments

Comments
 (0)