Skip to content

Commit cabfd79

Browse files
Fix 16bit assert. Update to use self.endpoint
1 parent 84f710d commit cabfd79

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/python_testing/TC_MOD_1_2.py

+15-13
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ def _verify_supported_mode(self, supported_mode):
9191
logger.info(
9292
"SupportedMode.semanticTags contains values, verifying attributes for manufacturedcode and value are not longer than 16bits int")
9393
for semantictag in supported_mode.semanticTags:
94-
asserts.assert_true(semantictag.mfgCode <= self._16bitshex, "Element semantictag.Mfgcode is greater than 16 bits")
95-
asserts.assert_true(semantictag.value <= self._16bitshex, "Element semantictag.Value is greater than 16 bits")
94+
asserts.assert_true(semantictag >= 0 and semantictag.mfgCode <= self._16bitshex,
95+
"Element semantictag.Mfgcode is greater than 16 bits")
96+
asserts.assert_true(semantictag >= 0 and semantictag.value <= self._16bitshex,
97+
"Element semantictag.Value is greater than 16 bits")
9698

9799
def _log_attribute(self, name, value):
98100
logger.info(f"{name} attribute {value} with type {type(value)}")
@@ -112,7 +114,7 @@ async def test_MOD_1_2(self):
112114
# Verify contains attributes label and mode
113115
# Verify if semantic tags has elements in list , and if there are values assert the values
114116
self.step(2)
115-
supported_modes = await self.read_single_attribute_check_success(endpoint=1, cluster=self.cluster, attribute=self.cluster.Attributes.SupportedModes)
117+
supported_modes = await self.read_single_attribute_check_success(endpoint=self.endpoint, cluster=self.cluster, attribute=self.cluster.Attributes.SupportedModes)
116118
logger.info(f"Supported modes {supported_modes}")
117119
# List must not be empty
118120
asserts.assert_true(len(supported_modes) > 0, "Supported modes can not be empty.")
@@ -128,32 +130,32 @@ async def test_MOD_1_2(self):
128130

129131
# Currentmode attribute check must be int and must be in the supported modes values.
130132
self.step(3)
131-
current_mode = await self.read_single_attribute_check_success(endpoint=1, cluster=self.cluster, attribute=self.cluster.Attributes.CurrentMode)
133+
current_mode = await self.read_single_attribute_check_success(endpoint=self.endpoint, cluster=self.cluster, attribute=self.cluster.Attributes.CurrentMode)
132134
self._log_attribute('CurrentMode', current_mode)
133135
asserts.assert_true(isinstance(current_mode, int), "Current mode is not int")
134136
asserts.assert_in(current_mode, supported_modes_values, f"Current mode {current_mode} is not in {supported_modes_values}")
135137

136-
# Onmode can be null
137138
self.step(4)
138-
on_mode = await self.read_single_attribute_check_success(endpoint=1, cluster=self.cluster, attribute=self.cluster.Attributes.OnMode)
139-
# on mode can be null
139+
on_mode = await self.read_single_attribute_check_success(endpoint=self.endpoint, cluster=self.cluster, attribute=self.cluster.Attributes.OnMode)
140+
# On mode can be null
140141
self._log_attribute("OnMode", on_mode)
141142
asserts.assert_true((isinstance(on_mode, int) or isinstance(on_mode, Nullable)),
142143
"Onmode is not int or is not clusters.Types.Nullable")
144+
# verify that OnMode is in the list of Supported Modes, but if null, cant be verified.
143145
if not isinstance(on_mode, Nullable):
144146
asserts.assert_in(on_mode, supported_modes_values, f"Onmode {current_mode} is not in {supported_modes_values}")
145147

146148
# Validate startup mode
147149
self.step(5)
148-
startup_mode = await self.read_single_attribute_check_success(endpoint=1, cluster=self.cluster, attribute=self.cluster.Attributes.StartUpMode)
150+
startup_mode = await self.read_single_attribute_check_success(endpoint=self.endpoint, cluster=self.cluster, attribute=self.cluster.Attributes.StartUpMode)
149151
self._log_attribute("StartupMode", startup_mode)
150152
asserts.assert_true(isinstance(startup_mode, int), "Startupmode is not int")
151153
asserts.assert_in(startup_mode, supported_modes_values, f"Startupmode {current_mode} is not in {supported_modes_values}")
152154

153155
# Verify the string for ci is larger that 1 char.
154156
# If is non ci ask the user if can read and understand the string.
155157
self.step(6)
156-
description = await self.read_single_attribute_check_success(endpoint=1, cluster=self.cluster, attribute=self.cluster.Attributes.Description)
158+
description = await self.read_single_attribute_check_success(endpoint=self.endpoint, cluster=self.cluster, attribute=self.cluster.Attributes.Description)
157159
self._log_attribute("Description", description)
158160
if self.is_ci:
159161
asserts.assert_true(isinstance(description, str), "Description attribute is not str")
@@ -164,12 +166,12 @@ async def test_MOD_1_2(self):
164166
default_value="y")
165167
asserts.assert_true(user_response.lower() == 'y', "The description is not understandable to the user.")
166168

167-
# Verify the StandardNamespace can be 16bits integer or null
169+
# Verify the StandardNamespace can be 16 bits enum or null
168170
self.step(7)
169-
standard_namepace = await self.read_single_attribute_check_success(endpoint=1, cluster=self.cluster, attribute=self.cluster.Attributes.StandardNamespace)
171+
standard_namepace = await self.read_single_attribute_check_success(endpoint=self.endpoint, cluster=self.cluster, attribute=self.cluster.Attributes.StandardNamespace)
170172
self._log_attribute("StandardNamespace", standard_namepace)
171-
asserts.assert_true((isinstance(standard_namepace, Nullable) or (isinstance(standard_namepace, int) and standard_namepace <= self._16bitshex)),
172-
"Standard namespace is not 16bit or not nullable")
173+
asserts.assert_true((isinstance(standard_namepace, Nullable) or (isinstance(standard_namepace, int) and (standard_namepace >= 0 and standard_namepace <= self._16bitshex))),
174+
"Standard namespace is not 16bit enum or not Nullable")
173175

174176

175177
if __name__ == "__main__":

0 commit comments

Comments
 (0)