@@ -131,20 +131,17 @@ async def test_TC_DGWIFI_2_1(self):
131131 # If not NULL, we expect an integer in the SecurityType enum range.
132132 # Just do a minimal check here; you can refine or extend based on the spec.
133133 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" )
136135
137136 # 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 )
142139
143140 # Additional check that it's not kUnknownEnumValue:
144141 self .assert_true (
145- security_type_value != Clusters .Objects .WiFiNetworkDiagnostics .Enums .SecurityTypeEnum .kUnknownEnumValue . value ,
142+ security_type != Clusters .Objects .WiFiNetworkDiagnostics .Enums .SecurityTypeEnum .kUnknownEnumValue ,
146143 f"SecurityType should not be kUnknownEnumValue "
147- f"({ Clusters .Objects .WiFiNetworkDiagnostics .Enums .SecurityTypeEnum .kUnknownEnumValue . value } )"
144+ f"({ Clusters .Objects .WiFiNetworkDiagnostics .Enums .SecurityTypeEnum .kUnknownEnumValue } )"
148145 )
149146
150147 #
@@ -154,16 +151,15 @@ async def test_TC_DGWIFI_2_1(self):
154151 wifi_version = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .WiFiVersion )
155152 # WiFiVersion is an enum. If not configured or operational, might be NULL.
156153 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" )
159155
160156 # 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 )
163159
164160 # 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 } )" )
167163
168164 #
169165 # STEP 5: TH reads ChannelNumber attribute
@@ -172,7 +168,7 @@ async def test_TC_DGWIFI_2_1(self):
172168 channel_number = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .ChannelNumber )
173169 # If not operational, might be NULL. Else we expect an unsigned integer channel.
174170 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" )
176172
177173 #
178174 # STEP 6: TH reads RSSI attribute
@@ -181,8 +177,7 @@ async def test_TC_DGWIFI_2_1(self):
181177 rssi = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .Rssi )
182178 # RSSI is typically a signed integer (dB). If not operational, might be NULL.
183179 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 ,
186181 "rssi_value is not within valid range." )
187182
188183 #
@@ -196,67 +191,52 @@ async def test_TC_DGWIFI_2_1(self):
196191 "BeaconLostCount must be of type 'Nullable' when not None." )
197192
198193 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" )
200195
201196 #
202197 # STEP 8: TH reads BeaconRxCount attribute
203198 #
204199 self .step (8 )
205200 beacon_rx_count = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .BeaconRxCount )
206201 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-
210202 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" )
212204
213205 #
214206 # STEP 9: TH reads PacketMulticastRxCount attribute
215207 #
216208 self .step (9 )
217209 pkt_multi_rx = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .PacketMulticastRxCount )
218210 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-
222211 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" )
224213
225214 #
226215 # STEP 10: TH reads PacketMulticastTxCount attribute
227216 #
228217 self .step (10 )
229218 pkt_multi_tx = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .PacketMulticastTxCount )
230219 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-
234220 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" )
236222
237223 #
238224 # STEP 11: TH reads PacketUnicastRxCount attribute
239225 #
240226 self .step (11 )
241227 pkt_uni_rx = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .PacketUnicastRxCount )
242228 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-
246229 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" )
248231
249232 #
250233 # STEP 12: TH reads PacketUnicastTxCount attribute
251234 #
252235 self .step (12 )
253236 pkt_uni_tx = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .PacketUnicastTxCount )
254237 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-
258238 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" )
260240
261241 #
262242 # STEP 13: TH reads CurrentMaxRate attribute
@@ -265,11 +245,8 @@ async def test_TC_DGWIFI_2_1(self):
265245 current_max_rate = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentMaxRate )
266246 # According to the spec, this is bytes per second (uint).
267247 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-
271248 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" )
273250
274251 #
275252 # STEP 14: TH reads OverrunCount attribute
@@ -278,11 +255,8 @@ async def test_TC_DGWIFI_2_1(self):
278255 overrun_count = await self .read_dgwifi_attribute_expect_success (endpoint = endpoint , attribute = attributes .OverrunCount )
279256 # This is a uint and may reset to 0 after node reboot.
280257 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-
284258 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" )
286260
287261
288262if __name__ == "__main__" :
0 commit comments