Skip to content

Commit

Permalink
address code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
asirko-soft committed Dec 19, 2024
1 parent 1a8d6b2 commit f80b10d
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions src/python_testing/TC_TCTL_2_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ def pics_TC_TCTL_2_3(self):
def steps_TC_TCTL_2_3(self) -> list[TestStep]:
steps = [
TestStep(1, "Commissioning, already done", is_commissioning=True),
TestStep(2, "TH reads from the DUT the SelectedTemperatureLevel attribute"),
TestStep(3, "TH reads from the DUT the SupportedTemperatureLevels attribute and verifies string lengths"),
TestStep(2, "TH reads from the DUT the SelectedTemperatureLevel attribute",
"Verify that the DUT response contains the value of _SelectedTemperatureLevel_ with a range of 0 to 31"),
TestStep(3, "TH reads from the DUT the SupportedTemperatureLevels attribute and verifies string lengths",
("Verify that the DUT response contains a _SupportedTemperatureLevels_ list\n\n"
"* List length hast to be equal or less than 32 \n"
"* Each temperature level should be a string\n"
"* Length of each temperature level string should be equal or less than 16\n")),
]
return steps

Expand All @@ -66,32 +71,30 @@ async def test_TC_TCTL_2_3(self):

# Step 2: Read SelectedTemperatureLevel attribute
self.step(2)
if self.attribute_guard(endpoint=self.endpoint, attribute=attributes.SelectedTemperatureLevel):
selected_temp = await self.read_single_attribute_check_success(
cluster=cluster,
attribute=cluster.Attributes.SelectedTemperatureLevel
)
asserts.assert_true(0 <= selected_temp <= 31,
f"SelectedTemperatureLevel {selected_temp} is out of range [0-31]")
selected_temp = await self.read_single_attribute_check_success(
cluster=cluster,
attribute=attributes.SelectedTemperatureLevel
)
asserts.assert_true(0 <= selected_temp <= 31,
f"SelectedTemperatureLevel {selected_temp} is out of range [0-31]")

# Step 3: Read SupportedTemperatureLevels attribute
self.step(3)
if self.attribute_guard(endpoint=self.endpoint, attribute=attributes.SupportedTemperatureLevels):
supported_temps = await self.read_single_attribute_check_success(
cluster=cluster,
attribute=cluster.Attributes.SupportedTemperatureLevels
)
asserts.assert_true(isinstance(supported_temps, list),
"SupportedTemperatureLevels should be a list")
asserts.assert_true(len(supported_temps) <= 32,
f"SupportedTemperatureLevels list length {len(supported_temps)} exceeds maximum of 32")
supported_temps = await self.read_single_attribute_check_success(
cluster=cluster,
attribute=attributes.SupportedTemperatureLevels
)
asserts.assert_true(isinstance(supported_temps, list),
"SupportedTemperatureLevels should be a list")
asserts.assert_true(len(supported_temps) <= 32,
f"SupportedTemperatureLevels list length {len(supported_temps)} exceeds maximum of 32")

# Verify string lengths
for level in supported_temps:
asserts.assert_true(isinstance(level, str),
f"Temperature level {level} is not a string")
asserts.assert_true(len(level) <= 16,
f"Temperature level string '{level}' exceeds maximum length of 16")
# Verify string lengths
for level in supported_temps:
asserts.assert_true(isinstance(level, str),
f"Temperature level {level} is not a string")
asserts.assert_true(len(level) <= 16,
f"Temperature level string '{level}' exceeds maximum length of 16")


if __name__ == "__main__":
Expand Down

0 comments on commit f80b10d

Please sign in to comment.