@@ -131,20 +131,17 @@ async def test_TC_DGWIFI_2_1(self):
131
131
# If not NULL, we expect an integer in the SecurityType enum range.
132
132
# Just do a minimal check here; you can refine or extend based on the spec.
133
133
if security_type is not NullValue :
134
- security_type_value = security_type .Value
135
- matter_asserts .assert_valid_uint8 (security_type_value , "SecurityType" )
134
+ matter_asserts .assert_valid_uint8 (security_type , "SecurityType" )
136
135
137
136
# Check if the security_type is a valid SecurityTypeEnum member
138
- self .assert_true (
139
- security_type_value in [item .value for item in Clusters .Objects .WiFiNetworkDiagnostics .Enums .SecurityTypeEnum ],
140
- f"SecurityType { security_type_value } is not a valid SecurityTypeEnum value"
141
- )
137
+ matter_asserts .assert_valid_enum (security_type , "SecurityType" ,
138
+ Clusters .Objects .WiFiNetworkDiagnostics .Enums .SecurityTypeEnum )
142
139
143
140
# Additional check that it's not kUnknownEnumValue:
144
141
self .assert_true (
145
- security_type_value != Clusters .Objects .WiFiNetworkDiagnostics .Enums .SecurityTypeEnum .kUnknownEnumValue . value ,
142
+ security_type != Clusters .Objects .WiFiNetworkDiagnostics .Enums .SecurityTypeEnum .kUnknownEnumValue ,
146
143
f"SecurityType should not be kUnknownEnumValue "
147
- f"({ Clusters .Objects .WiFiNetworkDiagnostics .Enums .SecurityTypeEnum .kUnknownEnumValue . value } )"
144
+ f"({ Clusters .Objects .WiFiNetworkDiagnostics .Enums .SecurityTypeEnum .kUnknownEnumValue } )"
148
145
)
149
146
150
147
#
@@ -154,16 +151,15 @@ async def test_TC_DGWIFI_2_1(self):
154
151
wifi_version = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .WiFiVersion )
155
152
# WiFiVersion is an enum. If not configured or operational, might be NULL.
156
153
if wifi_version is not NullValue :
157
- wifi_version_value = wifi_version .Value
158
- matter_asserts .assert_valid_uint8 (wifi_version_value , "WiFiVersion" )
154
+ matter_asserts .assert_valid_uint8 (wifi_version , "WiFiVersion" )
159
155
160
156
# Check if the wifi_version is a valid WiFiVersionEnum member
161
- self . assert_true ( wifi_version_value in [ item . value for item in Clusters . Objects . WiFiNetworkDiagnostics . Enums . WiFiVersionEnum ] ,
162
- f"WiFiVersion { wifi_version_value } is not a valid WiFiVersionEnum value" )
157
+ matter_asserts . assert_valid_enum ( wifi_version , "WiFiVersion" ,
158
+ Clusters . Objects . WiFiNetworkDiagnostics . Enums . WiFiVersionEnum )
163
159
164
160
# Additional check that it's not kUnknownEnumValue:
165
- self .assert_true (wifi_version_value != Clusters .Objects .WiFiNetworkDiagnostics .Enums .WiFiVersionEnum .kUnknownEnumValue . value ,
166
- f"WiFiVersion should not be kUnknownEnumValue ({ Clusters .Objects .WiFiNetworkDiagnostics .Enums .WiFiVersionEnum .kUnknownEnumValue . value } )" )
161
+ self .assert_true (wifi_version != Clusters .Objects .WiFiNetworkDiagnostics .Enums .WiFiVersionEnum .kUnknownEnumValue ,
162
+ f"WiFiVersion should not be kUnknownEnumValue ({ Clusters .Objects .WiFiNetworkDiagnostics .Enums .WiFiVersionEnum .kUnknownEnumValue } )" )
167
163
168
164
#
169
165
# STEP 5: TH reads ChannelNumber attribute
@@ -172,7 +168,7 @@ async def test_TC_DGWIFI_2_1(self):
172
168
channel_number = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .ChannelNumber )
173
169
# If not operational, might be NULL. Else we expect an unsigned integer channel.
174
170
if channel_number is not NullValue :
175
- matter_asserts .assert_valid_uint16 (channel_number . Value , "ChannelNumber" )
171
+ matter_asserts .assert_valid_uint16 (channel_number , "ChannelNumber" )
176
172
177
173
#
178
174
# STEP 6: TH reads RSSI attribute
@@ -181,8 +177,7 @@ async def test_TC_DGWIFI_2_1(self):
181
177
rssi = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .Rssi )
182
178
# RSSI is typically a signed integer (dB). If not operational, might be NULL.
183
179
if rssi is not NullValue :
184
- rssi_value = rssi .Value
185
- asserts .assert_true (isinstance (rssi_value , int ) and - 120 <= rssi_value <= 0 ,
180
+ asserts .assert_true (isinstance (rssi , int ) and - 120 <= rssi <= 0 ,
186
181
"rssi_value is not within valid range." )
187
182
188
183
#
@@ -196,67 +191,52 @@ async def test_TC_DGWIFI_2_1(self):
196
191
"BeaconLostCount must be of type 'Nullable' when not None." )
197
192
198
193
if beacon_lost_count is not NullValue :
199
- matter_asserts .assert_valid_uint32 (beacon_lost_count . Value , "BeaconLostCount" )
194
+ matter_asserts .assert_valid_uint32 (beacon_lost_count , "BeaconLostCount" )
200
195
201
196
#
202
197
# STEP 8: TH reads BeaconRxCount attribute
203
198
#
204
199
self .step (8 )
205
200
beacon_rx_count = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .BeaconRxCount )
206
201
if beacon_rx_count is not None :
207
- asserts .assert_true (isinstance (beacon_rx_count , Nullable ),
208
- "BeaconRxCount must be of type 'Nullable' when not None." )
209
-
210
202
if beacon_rx_count is not NullValue :
211
- matter_asserts .assert_valid_uint32 (beacon_rx_count . Value , "BeaconRxCount" )
203
+ matter_asserts .assert_valid_uint32 (beacon_rx_count , "BeaconRxCount" )
212
204
213
205
#
214
206
# STEP 9: TH reads PacketMulticastRxCount attribute
215
207
#
216
208
self .step (9 )
217
209
pkt_multi_rx = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .PacketMulticastRxCount )
218
210
if pkt_multi_rx is not None :
219
- asserts .assert_true (isinstance (pkt_multi_rx , Nullable ),
220
- "PacketMulticastRxCount must be of type 'Nullable' when not None." )
221
-
222
211
if pkt_multi_rx is not NullValue :
223
- matter_asserts .assert_valid_uint32 (pkt_multi_rx . Value , "PacketMulticastRxCount" )
212
+ matter_asserts .assert_valid_uint32 (pkt_multi_rx , "PacketMulticastRxCount" )
224
213
225
214
#
226
215
# STEP 10: TH reads PacketMulticastTxCount attribute
227
216
#
228
217
self .step (10 )
229
218
pkt_multi_tx = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .PacketMulticastTxCount )
230
219
if pkt_multi_tx is not None :
231
- asserts .assert_true (isinstance (pkt_multi_tx , Nullable ),
232
- "PacketMulticastTxCount must be of type 'Nullable' when not None." )
233
-
234
220
if pkt_multi_tx is not NullValue :
235
- matter_asserts .assert_valid_uint32 (pkt_multi_tx . Value , "PacketMulticastTxCount" )
221
+ matter_asserts .assert_valid_uint32 (pkt_multi_tx , "PacketMulticastTxCount" )
236
222
237
223
#
238
224
# STEP 11: TH reads PacketUnicastRxCount attribute
239
225
#
240
226
self .step (11 )
241
227
pkt_uni_rx = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .PacketUnicastRxCount )
242
228
if pkt_uni_rx is not None :
243
- asserts .assert_true (isinstance (pkt_uni_rx , Nullable ),
244
- "PacketUnicastRxCount must be of type 'Nullable' when not None." )
245
-
246
229
if pkt_uni_rx is not NullValue :
247
- matter_asserts .assert_valid_uint32 (pkt_uni_rx . Value , "PacketUnicastRxCount" )
230
+ matter_asserts .assert_valid_uint32 (pkt_uni_rx , "PacketUnicastRxCount" )
248
231
249
232
#
250
233
# STEP 12: TH reads PacketUnicastTxCount attribute
251
234
#
252
235
self .step (12 )
253
236
pkt_uni_tx = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .PacketUnicastTxCount )
254
237
if pkt_uni_tx is not None :
255
- asserts .assert_true (isinstance (pkt_uni_tx , Nullable ),
256
- "PacketUnicastTxCount must be of type 'Nullable' when not None." )
257
-
258
238
if pkt_uni_tx is not NullValue :
259
- matter_asserts .assert_valid_uint32 (pkt_uni_tx . Value , "PacketUnicastTxCount" )
239
+ matter_asserts .assert_valid_uint32 (pkt_uni_tx , "PacketUnicastTxCount" )
260
240
261
241
#
262
242
# STEP 13: TH reads CurrentMaxRate attribute
@@ -265,11 +245,8 @@ async def test_TC_DGWIFI_2_1(self):
265
245
current_max_rate = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentMaxRate )
266
246
# According to the spec, this is bytes per second (uint).
267
247
if current_max_rate is not None :
268
- asserts .assert_true (isinstance (current_max_rate , Nullable ),
269
- "CurrentMaxRate must be of type 'Nullable' when not None." )
270
-
271
248
if current_max_rate is not NullValue :
272
- matter_asserts .assert_valid_uint64 (current_max_rate . Value , "CurrentMaxRate" )
249
+ matter_asserts .assert_valid_uint64 (current_max_rate , "CurrentMaxRate" )
273
250
274
251
#
275
252
# STEP 14: TH reads OverrunCount attribute
@@ -278,11 +255,8 @@ async def test_TC_DGWIFI_2_1(self):
278
255
overrun_count = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .OverrunCount )
279
256
# This is a uint and may reset to 0 after node reboot.
280
257
if overrun_count is not None :
281
- asserts .assert_true (isinstance (overrun_count , Nullable ),
282
- "OverrunCount must be of type 'Nullable' when not None." )
283
-
284
258
if overrun_count is not NullValue :
285
- matter_asserts .assert_valid_uint64 (overrun_count . Value , "OverrunCount" )
259
+ matter_asserts .assert_valid_uint64 (overrun_count , "OverrunCount" )
286
260
287
261
288
262
if __name__ == "__main__" :
0 commit comments