32
32
# --qr-code MT:-24J0AFN00KA0648G00
33
33
# --trace-to json:log
34
34
# factoryreset: True
35
- # quiet: True
35
+ # quiet: False
36
36
# === END CI TEST ARGUMENTS ===
37
37
38
38
39
39
import chip .clusters as Clusters
40
40
from chip import ChipDeviceCtrl
41
41
from chip .commissioning import ROOT_ENDPOINT_ID
42
+ from chip .clusters .Attribute import AsyncReadTransaction , ValueDecodeFailure
42
43
from chip .testing .matter_testing import MatterBaseTest , TestStep , async_test_body , default_matter_test_main
43
44
from mobly import asserts
44
45
@@ -68,9 +69,10 @@ async def test_TC_CGEN_2_5(self):
68
69
69
70
# Step 1: Begin commissioning with PASE and failsafe
70
71
self .step (1 )
71
- commissioner .SetTCRequired (False )
72
72
commissioner .SetSkipCommissioningComplete (True )
73
73
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
74
76
await self .commission_devices ()
75
77
76
78
# Step 2: Read TCAcknowledgementsRequired
@@ -83,19 +85,24 @@ async def test_TC_CGEN_2_5(self):
83
85
84
86
# Step 3: Read TCUpdateDeadline
85
87
self .step (3 )
86
- response = await commissioner .ReadAttribute (
88
+ response : AsyncReadTransaction . ReadResponse . attributes = await commissioner .ReadAttribute (
87
89
nodeid = self .dut_node_id ,
88
90
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' )
91
98
92
99
# Step 4: Read FeatureMap
93
100
self .step (4 )
94
101
response = await commissioner .ReadAttribute (
95
102
nodeid = self .dut_node_id ,
96
103
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' )
99
106
100
107
# Step 5: Send SetTCAcknowledgements
101
108
self .step (5 )
@@ -145,20 +152,20 @@ async def test_TC_CGEN_2_5(self):
145
152
146
153
# Step 9: Verify TCAcceptedVersion
147
154
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' )
151
158
152
159
# Step 10: Verify TCAcknowledgements
153
160
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' )
157
164
158
165
# Step 11: Verify TCMinRequiredVersion
159
166
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' )
162
169
163
170
# Step 12: Verify TCAcknowledgementsRequired
164
171
self .step (12 )
0 commit comments