Skip to content

Commit 175ae17

Browse files
Revert "Removed types defined on class variables as string and moved to Enum."
Pull integrated changes from submodules. This reverts commit e61e144.
1 parent 1bff3bb commit 175ae17

File tree

16 files changed

+65
-70
lines changed

16 files changed

+65
-70
lines changed

src/python_testing/TC_CC_2_1.py

+50-55
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
# === END CI TEST ARGUMENTS ===
3737

3838
import logging
39-
from enum import Enum
4039
from typing import Optional
4140

4241
import chip.clusters as Clusters
@@ -49,15 +48,6 @@
4948
logger = logging.getLogger(__name__)
5049

5150

52-
class ValueTypesEnum(Enum):
53-
"""Data types to validate in this case."""
54-
UINT8 = 1
55-
UINT16 = 2
56-
UINT32 = 3
57-
STRING = 4
58-
ENUM = 5
59-
60-
6151
class TC_CC_2_1(MatterBaseTest):
6252

6353
def desc_TC_CC_2_1(self) -> str:
@@ -143,12 +133,12 @@ def steps_TC_CC_2_1(self) -> list[TestStep]:
143133

144134
return steps
145135

146-
async def _verify_attribute(self, attribute: Attribute, data_type: ValueTypesEnum, enum_range: Optional[list] = None, min_len: Optional[int] = None, max_len: Optional[int] = None):
136+
async def _verify_attribute(self, attribute: Attribute, data_type: str, enum_range: Optional[list] = None, min_len: Optional[int] = None, max_len: Optional[int] = None):
147137
"""Verify the attribute exists and value is the specific type of value.
148138
149139
Args:
150140
attribute (Attribute): Name of the attribute we want to retrieve
151-
data_type (ValueTypesEnum): type of data we want to validate against (uint8,uint16,uint32,string,enum)
141+
data_type (str): type of data we want to validate against (uint8,uint16,uint32,string,enum)
152142
enum_range (list, optional): Range that the enum may have. 0-2 or 0-5. Defaults to Optional[list].
153143
min_len (int, optional): If present verify the low range of the attribute.
154144
max_len (int, optional): If present verify the high range of the attribute.
@@ -160,33 +150,33 @@ async def _verify_attribute(self, attribute: Attribute, data_type: ValueTypesEnu
160150
# it is so retrieve the value to check the type.
161151
attr_val = await self.read_single_attribute_check_success(cluster=self.cluster, attribute=attribute, endpoint=self.endpoint)
162152
logger.info(f"Current value for {attribute} is {attr_val}")
163-
if data_type == ValueTypesEnum.UINT8:
153+
if data_type == self.UINT8:
164154
logger.info("Checkng is uint8")
165155
matter_asserts.assert_valid_uint8(attr_val, "Is not uint8")
166-
elif data_type == ValueTypesEnum.UINT16:
156+
elif data_type == self.UINT16:
167157
logger.info("Checkng is uint16")
168158
matter_asserts.assert_valid_uint16(attr_val, "Is not uint16")
169-
elif data_type == ValueTypesEnum.UINT32:
159+
elif data_type == self.UINT32:
170160
logger.info("Checkng is uint32")
171161
matter_asserts.assert_valid_uint32(attr_val, "Is not uint32")
172-
elif data_type == ValueTypesEnum.ENUM:
162+
elif data_type == self.ENUM:
173163
if len(enum_range) >= 0:
174164
logger.info(f"Checking for enum with range {enum_range}")
175165
asserts.assert_in(attr_val, enum_range, f"Value is not in range for enum with range {enum_range}")
176166
else:
177167
asserts.fail("Range list is empty")
178-
elif data_type == ValueTypesEnum.STRING and isinstance(attr_val, str):
168+
elif data_type == self.STRING and isinstance(attr_val, str):
179169
if max_len > 0:
180170
logger.info(f"Validating string with a max len of {max_len}")
181171
asserts.assert_true((len(attr_val) <= max_len), "String len is out of range.")
182172
else:
183-
asserts.fail("Invalid String range provided.")
173+
asserts.fail("FAILED")
184174
else:
185175
asserts.fail("Validation not possible as not data type provided.")
186176

187177
# if we land at this point it mean validation had passed
188178
# check if string has uint and verify is we need to compare against a min or max value
189-
if 'uint' in data_type.name.lower() and (max_len is not None or min_len is not None):
179+
if 'uint' in data_type and (max_len is not None or min_len is not None):
190180
if isinstance(min_len, int):
191181
logger.info(f"Min len defined validation max range for uint {min_len}")
192182
asserts.assert_true((attr_val >= min_len),
@@ -225,80 +215,85 @@ def _verify_first_4bits(self, numa, numb):
225215

226216
@async_test_body
227217
async def test_TC_CC_2_1(self):
218+
self.UINT8 = "uint8"
219+
self.UINT16 = "uint16"
220+
self.UINT32 = 'uint32'
221+
self.STRING = "string"
222+
self.ENUM = "enum"
228223
self.cluster = Clusters.ColorControl
229224
self.endpoint = self.get_endpoint(1)
230225
self.attributes = Clusters.ColorControl.Attributes
231226

232227
self.step(1)
233228

234229
self.step(2)
235-
await self._verify_attribute(self.attributes.CurrentHue, ValueTypesEnum.UINT8)
230+
await self._verify_attribute(self.attributes.CurrentHue, self.UINT8)
236231

237232
self.step(3)
238-
await self._verify_attribute(self.attributes.CurrentSaturation, ValueTypesEnum.UINT8)
233+
await self._verify_attribute(self.attributes.CurrentSaturation, self.UINT8)
239234

240235
self.step(4)
241-
await self._verify_attribute(self.attributes.RemainingTime, ValueTypesEnum.UINT16)
236+
await self._verify_attribute(self.attributes.RemainingTime, self.UINT16)
242237

243238
self.step(5)
244-
await self._verify_attribute(self.attributes.CurrentX, ValueTypesEnum.UINT16, max_len=0xfeff)
239+
await self._verify_attribute(self.attributes.CurrentX, self.UINT16, max_len=0xfeff)
245240

246241
self.step(6)
247-
await self._verify_attribute(self.attributes.CurrentY, ValueTypesEnum.UINT16, max_len=0xfeff)
242+
await self._verify_attribute(self.attributes.CurrentY, self.UINT16, max_len=0xfeff)
248243

249244
self.step(7)
250-
await self._verify_attribute(self.attributes.DriftCompensation, ValueTypesEnum.ENUM, enum_range=range(0, 5))
245+
await self._verify_attribute(self.attributes.DriftCompensation, self.ENUM, enum_range=range(0, 5))
251246

252247
self.step(8)
253-
await self._verify_attribute(self.attributes.CompensationText, ValueTypesEnum.STRING, max_len=254)
248+
await self._verify_attribute(self.attributes.CompensationText, self.STRING, max_len=254)
254249

255250
self.step(9)
256-
await self._verify_attribute(self.attributes.ColorTemperatureMireds, ValueTypesEnum.UINT16, min_len=1, max_len=0xfeff)
251+
await self._verify_attribute(self.attributes.ColorTemperatureMireds, self.UINT16, min_len=1, max_len=0xfeff)
257252

258253
self.step(10)
259-
await self._verify_attribute(self.attributes.ColorMode, ValueTypesEnum.ENUM, enum_range=range(0, 3))
254+
await self._verify_attribute(self.attributes.ColorMode, self.ENUM, enum_range=range(0, 3))
260255

261256
self.step(11)
262-
await self._verify_attribute(self.attributes.Options, ValueTypesEnum.UINT8, max_len=4)
257+
await self._verify_attribute(self.attributes.Options, self.UINT8, max_len=4)
263258

264259
self.step(12)
265-
await self._verify_attribute(self.attributes.EnhancedCurrentHue, ValueTypesEnum.UINT16)
260+
await self._verify_attribute(self.attributes.EnhancedCurrentHue, self.UINT16)
266261

267262
self.step(13)
268-
await self._verify_attribute(self.attributes.EnhancedColorMode, ValueTypesEnum.ENUM, enum_range=range(0, 4))
263+
await self._verify_attribute(self.attributes.EnhancedColorMode, self.ENUM, enum_range=range(0, 4))
269264

270265
self.step(14)
271-
await self._verify_attribute(self.attributes.ColorLoopActive, ValueTypesEnum.UINT8)
266+
await self._verify_attribute(self.attributes.ColorLoopActive, self.UINT8)
272267

273268
self.step(15)
274-
await self._verify_attribute(self.attributes.ColorLoopDirection, ValueTypesEnum.UINT8)
269+
await self._verify_attribute(self.attributes.ColorLoopDirection, self.UINT8)
275270

276271
self.step(16)
277-
await self._verify_attribute(self.attributes.ColorLoopTime, ValueTypesEnum.UINT16)
272+
await self._verify_attribute(self.attributes.ColorLoopTime, self.UINT16)
278273

279274
self.step(17)
280-
await self._verify_attribute(self.attributes.ColorLoopStartEnhancedHue, ValueTypesEnum.UINT16)
275+
await self._verify_attribute(self.attributes.ColorLoopStartEnhancedHue, self.UINT16)
281276

282277
self.step(18)
283-
await self._verify_attribute(self.attributes.ColorLoopStoredEnhancedHue, ValueTypesEnum.UINT16)
278+
await self._verify_attribute(self.attributes.ColorLoopStoredEnhancedHue, self.UINT16)
284279

285280
self.step("18.a")
286281
# read and save FeatureMap attribute
287282
feature_map_value = await self.read_single_attribute_check_success(cluster=self.cluster, endpoint=self.endpoint, attribute=self.attributes.FeatureMap)
288283

289284
self.step(19)
290-
color_capabilities_value = await self._verify_attribute(self.attributes.ColorCapabilities, ValueTypesEnum.UINT16, max_len=0x001f)
285+
color_capabilities_value = await self._verify_attribute(self.attributes.ColorCapabilities, self.UINT16, max_len=0x001f)
291286
# verify the first 4 bits of colorcapabilities are the same on FeatureMap
292287
self._verify_first_4bits(feature_map_value, color_capabilities_value)
293288

294289
self.step(20)
295-
colortempphysicalminmireds_val = await self._verify_attribute(self.attributes.ColorTempPhysicalMinMireds, ValueTypesEnum.UINT16, min_len=1, max_len=0xfeff)
290+
colortempphysicalminmireds_val = await self._verify_attribute(self.attributes.ColorTempPhysicalMinMireds, self.UINT16, min_len=1, max_len=0xfeff)
296291

297292
self.step(21)
298-
colortempphysicalmaxmireds_val = await self._verify_attribute(self.attributes.ColorTempPhysicalMaxMireds, ValueTypesEnum.UINT16, min_len=1, max_len=0xfeff)
293+
colortempphysicalmaxmireds_val = await self._verify_attribute(self.attributes.ColorTempPhysicalMaxMireds, self.UINT16, min_len=1, max_len=0xfeff)
299294

300295
self.step(22)
301-
await self._verify_attribute(self.attributes.CoupleColorTempToLevelMinMireds, ValueTypesEnum.UINT16, min_len=colortempphysicalminmireds_val, max_len=colortempphysicalmaxmireds_val)
296+
await self._verify_attribute(self.attributes.CoupleColorTempToLevelMinMireds, self.UINT16, min_len=colortempphysicalminmireds_val, max_len=colortempphysicalmaxmireds_val)
302297

303298
self.step(23)
304299
# Manual check
@@ -311,7 +306,7 @@ async def test_TC_CC_2_1(self):
311306
# Issue: #9103 to address remove 0 in NumberofPrimaries.
312307
# After this is resolved, check not 0.
313308
self.step(24)
314-
numberofprimaries_value = await self._verify_attribute(self.attributes.NumberOfPrimaries, ValueTypesEnum.UINT8, max_len=6)
309+
numberofprimaries_value = await self._verify_attribute(self.attributes.NumberOfPrimaries, self.UINT8, max_len=6)
315310
# Verify for numberofprimaries section
316311
# We are at step 24 before all the number of primaries checks
317312
current_step = 24
@@ -328,47 +323,47 @@ async def test_TC_CC_2_1(self):
328323
# Get the attributes to check then perform guard (at _verify_attribute)
329324
current_step += 1
330325
self.step(current_step)
331-
await self._verify_attribute(getattr(self.attributes, f"Primary{primariesindex}X"), ValueTypesEnum.UINT16, max_len=0xfeff)
326+
await self._verify_attribute(getattr(self.attributes, f"Primary{primariesindex}X"), self.UINT16, max_len=0xfeff)
332327
current_step += 1
333328
self.step(current_step)
334-
await self._verify_attribute(getattr(self.attributes, f"Primary{primariesindex}Y"), ValueTypesEnum.UINT16, max_len=0xfeff)
329+
await self._verify_attribute(getattr(self.attributes, f"Primary{primariesindex}Y"), self.UINT16, max_len=0xfeff)
335330
current_step += 1
336331
self.step(current_step)
337-
await self._verify_attribute(getattr(self.attributes, f"Primary{primariesindex}Intensity"), ValueTypesEnum.UINT8)
332+
await self._verify_attribute(getattr(self.attributes, f"Primary{primariesindex}Intensity"), self.UINT8)
338333

339334
# No more check numberofprimaries at this point
340335
self.step(43)
341-
await self._verify_attribute(self.attributes.WhitePointX, ValueTypesEnum.UINT16, max_len=0xfeff)
336+
await self._verify_attribute(self.attributes.WhitePointX, self.UINT16, max_len=0xfeff)
342337

343338
self.step(44)
344-
await self._verify_attribute(self.attributes.WhitePointY, ValueTypesEnum.UINT16, max_len=0xfeff)
339+
await self._verify_attribute(self.attributes.WhitePointY, self.UINT16, max_len=0xfeff)
345340

346341
self.step(45)
347-
await self._verify_attribute(self.attributes.ColorPointRX, ValueTypesEnum.UINT16, max_len=0xfeff)
342+
await self._verify_attribute(self.attributes.ColorPointRX, self.UINT16, max_len=0xfeff)
348343

349344
self.step(46)
350-
await self._verify_attribute(self.attributes.ColorPointRY, ValueTypesEnum.UINT16, max_len=0xfeff)
345+
await self._verify_attribute(self.attributes.ColorPointRY, self.UINT16, max_len=0xfeff)
351346

352347
self.step(47)
353-
await self._verify_attribute(self.attributes.ColorPointRIntensity, ValueTypesEnum.UINT8)
348+
await self._verify_attribute(self.attributes.ColorPointRIntensity, self.UINT8)
354349

355350
self.step(48)
356-
await self._verify_attribute(self.attributes.ColorPointGX, ValueTypesEnum.UINT16, max_len=0xfeff)
351+
await self._verify_attribute(self.attributes.ColorPointGX, self.UINT16, max_len=0xfeff)
357352

358353
self.step(49)
359-
await self._verify_attribute(self.attributes.ColorPointGY, ValueTypesEnum.UINT16, max_len=0xfeff)
354+
await self._verify_attribute(self.attributes.ColorPointGY, self.UINT16, max_len=0xfeff)
360355

361356
self.step(50)
362-
await self._verify_attribute(self.attributes.ColorPointGIntensity, ValueTypesEnum.UINT8)
357+
await self._verify_attribute(self.attributes.ColorPointGIntensity, self.UINT8)
363358

364359
self.step(51)
365-
await self._verify_attribute(self.attributes.ColorPointBX, ValueTypesEnum.UINT16, max_len=0xfeff)
360+
await self._verify_attribute(self.attributes.ColorPointBX, self.UINT16, max_len=0xfeff)
366361

367362
self.step(52)
368-
await self._verify_attribute(self.attributes.ColorPointBY, ValueTypesEnum.UINT16, max_len=0xfeff)
363+
await self._verify_attribute(self.attributes.ColorPointBY, self.UINT16, max_len=0xfeff)
369364

370365
self.step(53)
371-
await self._verify_attribute(self.attributes.ColorPointBIntensity, ValueTypesEnum.UINT8)
366+
await self._verify_attribute(self.attributes.ColorPointBIntensity, self.UINT8)
372367

373368

374369
if __name__ == "__main__":

third_party/bouffalolab/repo

Submodule repo updated 1 file

third_party/imgui/repo

Submodule repo updated 139 files

third_party/libwebsockets/repo

Submodule repo updated 131 files

third_party/lwip/repo

Submodule repo updated 108 files

third_party/mbedtls/repo

Submodule repo updated from 5bc604f to 2153b1b

third_party/openthread/repo

Submodule repo updated 441 files

third_party/ot-br-posix/repo

Submodule repo updated 228 files

third_party/pigweed/repo

Submodule repo updated 2748 files

third_party/silabs/matter_support

Submodule matter_support updated 195 files

third_party/silabs/simplicity_sdk

Submodule simplicity_sdk updated 6579 files

third_party/silabs/wifi_sdk

Submodule wifi_sdk updated 794 files

0 commit comments

Comments
 (0)