Skip to content

Commit

Permalink
VALCC: Remove top-level PICS
Browse files Browse the repository at this point in the history
Self-select the valve tests off the device information
rather than the PICS. This makes it easier to run the tests
since you can just run them all unconditionally and they
will run if required.
  • Loading branch information
cecille committed Sep 30, 2024
1 parent e0195d7 commit eb2dcbf
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 250 deletions.
12 changes: 3 additions & 9 deletions src/python_testing/TC_VALCC_2_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import chip.clusters as Clusters
from chip.clusters.Types import NullValue
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
from matter_testing_support import MatterBaseTest, TestStep, default_matter_test_main, has_cluster, run_if_endpoint_matches
from mobly import asserts


Expand Down Expand Up @@ -58,16 +58,10 @@ def steps_TC_VALCC_2_1(self) -> list[TestStep]:
]
return steps

def pics_TC_VALCC_2_1(self) -> list[str]:
pics = [
"VALCC.S",
]
return pics

@async_test_body
@run_if_endpoint_matches(has_cluster(Clusters.ValveConfigurationAndControl))
async def test_TC_VALCC_2_1(self):

endpoint = self.user_params.get("endpoint", 1)
endpoint = self.matter_test_config.endpoint

self.step(1)
attributes = Clusters.ValveConfigurationAndControl.Attributes
Expand Down
12 changes: 3 additions & 9 deletions src/python_testing/TC_VALCC_3_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import chip.clusters as Clusters
from chip.clusters.Types import NullValue
from chip.interaction_model import InteractionModelError, Status
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
from matter_testing_support import MatterBaseTest, TestStep, default_matter_test_main, has_cluster, run_if_endpoint_matches
from mobly import asserts


Expand All @@ -55,16 +55,10 @@ def steps_TC_VALCC_3_1(self) -> list[TestStep]:
]
return steps

def pics_TC_VALCC_3_1(self) -> list[str]:
pics = [
"VALCC.S",
]
return pics

@async_test_body
@run_if_endpoint_matches(has_cluster(Clusters.ValveConfigurationAndControl))
async def test_TC_VALCC_3_1(self):

endpoint = self.user_params.get("endpoint", 1)
endpoint = self.matter_test_config.endpoint

self.step(1)
cluster = Clusters.ValveConfigurationAndControl
Expand Down
94 changes: 34 additions & 60 deletions src/python_testing/TC_VALCC_3_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import chip.clusters as Clusters
from chip.clusters.Types import NullValue
from chip.interaction_model import InteractionModelError, Status
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
from matter_testing_support import MatterBaseTest, TestStep, default_matter_test_main, has_feature, run_if_endpoint_matches
from mobly import asserts


Expand All @@ -55,92 +55,66 @@ def steps_TC_VALCC_3_2(self) -> list[TestStep]:
]
return steps

def pics_TC_VALCC_3_2(self) -> list[str]:
pics = [
"VALCC.S",
]
return pics

@async_test_body
@run_if_endpoint_matches(has_feature(Clusters.ValveConfigurationAndControl, Clusters.ValveConfigurationAndControl.Bitmaps.Feature.kLevel))
async def test_TC_VALCC_3_2(self):

endpoint = self.user_params.get("endpoint", 1)
endpoint = self.matter_test_config.endpoint

self.step(1)
attributes = Clusters.ValveConfigurationAndControl.Attributes

self.step(2)
feature_map = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap)

is_lvl_feature_supported = feature_map & Clusters.ValveConfigurationAndControl.Bitmaps.Feature.kLevel
# Done as part of the test initialization

self.step(3)
if is_lvl_feature_supported:
try:
await self.send_single_cmd(cmd=Clusters.Objects.ValveConfigurationAndControl.Commands.Open(targetLevel=100), endpoint=endpoint)
except InteractionModelError as e:
asserts.assert_equal(e.status, Status.Success, "Unexpected error returned")
pass
else:
logging.info("Test step skipped")
try:
await self.send_single_cmd(cmd=Clusters.Objects.ValveConfigurationAndControl.Commands.Open(targetLevel=100), endpoint=endpoint)
except InteractionModelError as e:
asserts.assert_equal(e.status, Status.Success, "Unexpected error returned")
pass

self.step(4)
if is_lvl_feature_supported:
target_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetLevel)
target_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetLevel)

asserts.assert_true(target_level_dut is not NullValue, "TargetLevel is null")
asserts.assert_equal(target_level_dut, 100, "TargetLevel is not the expected value")
else:
logging.info("Test step skipped")
asserts.assert_true(target_level_dut is not NullValue, "TargetLevel is null")
asserts.assert_equal(target_level_dut, 100, "TargetLevel is not the expected value")

self.step(5)
if is_lvl_feature_supported:
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")

while current_level_dut != 100:
time.sleep(1)
while current_level_dut != 100:
time.sleep(1)

current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")

asserts.assert_equal(current_level_dut, 100, "CurrentLevel is not the expected value")
else:
logging.info("Test step skipped")
asserts.assert_equal(current_level_dut, 100, "CurrentLevel is not the expected value")

self.step(6)
if is_lvl_feature_supported:
try:
await self.send_single_cmd(cmd=Clusters.Objects.ValveConfigurationAndControl.Commands.Close(), endpoint=endpoint)
except InteractionModelError as e:
asserts.assert_equal(e.status, Status.Success, "Unexpected error returned")
pass
else:
logging.info("Test step skipped")
try:
await self.send_single_cmd(cmd=Clusters.Objects.ValveConfigurationAndControl.Commands.Close(), endpoint=endpoint)
except InteractionModelError as e:
asserts.assert_equal(e.status, Status.Success, "Unexpected error returned")
pass

self.step(7)
if is_lvl_feature_supported:
target_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetLevel)
target_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetLevel)

asserts.assert_true(target_level_dut is not NullValue, "TargetLevel is null")
asserts.assert_equal(target_level_dut, 0, "TargetLevel is not the expected value")
else:
logging.info("Test step skipped")
asserts.assert_true(target_level_dut is not NullValue, "TargetLevel is null")
asserts.assert_equal(target_level_dut, 0, "TargetLevel is not the expected value")

self.step(8)
if is_lvl_feature_supported:
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")

while current_level_dut is Clusters.Objects.ValveConfigurationAndControl.Enums.ValveStateEnum.kTransitioning:
time.sleep(1)
while current_level_dut is Clusters.Objects.ValveConfigurationAndControl.Enums.ValveStateEnum.kTransitioning:
time.sleep(1)

current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")

asserts.assert_equal(current_level_dut, 0, "CurrentLevel is not the expected value")
else:
logging.info("Test step skipped")
asserts.assert_equal(current_level_dut, 0, "CurrentLevel is not the expected value")


if __name__ == "__main__":
Expand Down
97 changes: 35 additions & 62 deletions src/python_testing/TC_VALCC_3_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import chip.clusters as Clusters
from chip.clusters.Types import NullValue
from chip.interaction_model import InteractionModelError, Status
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
from matter_testing_support import MatterBaseTest, TestStep, default_matter_test_main, has_attribute, run_if_endpoint_matches
from mobly import asserts


Expand All @@ -56,96 +56,69 @@ def steps_TC_VALCC_3_3(self) -> list[TestStep]:
]
return steps

def pics_TC_VALCC_3_3(self) -> list[str]:
pics = [
"VALCC.S",
]
return pics

@async_test_body
@run_if_endpoint_matches(has_attribute(Clusters.ValveConfigurationAndControl.Attributes.DefaultOpenLevel))
async def test_TC_VALCC_3_3(self):

endpoint = self.user_params.get("endpoint", 1)
endpoint = self.matter_test_config.endpoint

self.step(1)
attributes = Clusters.ValveConfigurationAndControl.Attributes

self.step(2)
attribute_list = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList)
# Done as part of the test initialization

self.step(3)
if attributes.DefaultOpenLevel.attribute_id in attribute_list:
defaultOpenLevel = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.DefaultOpenLevel)
else:
logging.info("Test step skipped")
defaultOpenLevel = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.DefaultOpenLevel)

self.step(4)
if attributes.DefaultOpenLevel.attribute_id in attribute_list:
try:
await self.send_single_cmd(cmd=Clusters.Objects.ValveConfigurationAndControl.Commands.Open(), endpoint=endpoint)
except InteractionModelError as e:
asserts.assert_equal(e.status, Status.Success, "Unexpected error returned")
pass
else:
logging.info("Test step skipped")
try:
await self.send_single_cmd(cmd=Clusters.Objects.ValveConfigurationAndControl.Commands.Open(), endpoint=endpoint)
except InteractionModelError as e:
asserts.assert_equal(e.status, Status.Success, "Unexpected error returned")
pass

self.step(5)
if attributes.DefaultOpenLevel.attribute_id in attribute_list:
target_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetLevel)
target_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetLevel)

asserts.assert_true(target_level_dut is not NullValue, "TargetLevel is null")
asserts.assert_equal(target_level_dut, defaultOpenLevel, "TargetLevel is not the expected value")
else:
logging.info("Test step skipped")
asserts.assert_true(target_level_dut is not NullValue, "TargetLevel is null")
asserts.assert_equal(target_level_dut, defaultOpenLevel, "TargetLevel is not the expected value")

self.step(6)
if attributes.DefaultOpenLevel.attribute_id in attribute_list:
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")

while current_level_dut != defaultOpenLevel:
time.sleep(1)
while current_level_dut != defaultOpenLevel:
time.sleep(1)

current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")

asserts.assert_equal(current_level_dut, defaultOpenLevel, "CurrentLevel is not the expected value")
else:
logging.info("Test step skipped")
asserts.assert_equal(current_level_dut, defaultOpenLevel, "CurrentLevel is not the expected value")

self.step(7)
if attributes.DefaultOpenLevel.attribute_id in attribute_list:
try:
await self.send_single_cmd(cmd=Clusters.Objects.ValveConfigurationAndControl.Commands.Close(), endpoint=endpoint)
except InteractionModelError as e:
asserts.assert_equal(e.status, Status.Success, "Unexpected error returned")
pass
else:
logging.info("Test step skipped")
try:
await self.send_single_cmd(cmd=Clusters.Objects.ValveConfigurationAndControl.Commands.Close(), endpoint=endpoint)
except InteractionModelError as e:
asserts.assert_equal(e.status, Status.Success, "Unexpected error returned")
pass

self.step(8)
if attributes.DefaultOpenLevel.attribute_id in attribute_list:
target_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetLevel)
target_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetLevel)

asserts.assert_true(target_level_dut is not NullValue, "TargetLevel is null")
asserts.assert_equal(target_level_dut, 0, "TargetLevel is not the expected value")
else:
logging.info("Test step skipped")
asserts.assert_true(target_level_dut is not NullValue, "TargetLevel is null")
asserts.assert_equal(target_level_dut, 0, "TargetLevel is not the expected value")

self.step(9)
if attributes.DefaultOpenLevel.attribute_id in attribute_list:
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")

while current_level_dut is Clusters.Objects.ValveConfigurationAndControl.Enums.ValveStateEnum.kTransitioning:
time.sleep(1)
while current_level_dut is Clusters.Objects.ValveConfigurationAndControl.Enums.ValveStateEnum.kTransitioning:
time.sleep(1)

current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")

asserts.assert_equal(current_level_dut, 0, "CurrentLevel is not the expected value")
else:
logging.info("Test step skipped")
asserts.assert_equal(current_level_dut, 0, "CurrentLevel is not the expected value")


if __name__ == "__main__":
Expand Down
27 changes: 4 additions & 23 deletions src/python_testing/TC_VALCC_3_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import chip.clusters as Clusters
from chip.interaction_model import InteractionModelError, Status
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
from matter_testing_support import MatterBaseTest, TestStep, default_matter_test_main, has_attribute, run_if_endpoint_matches
from mobly import asserts


Expand All @@ -51,36 +51,17 @@ def steps_TC_VALCC_3_4(self) -> list[TestStep]:
]
return steps

def pics_TC_VALCC_3_4(self) -> list[str]:
pics = [
"VALCC.S",
]
return pics

@async_test_body
@run_if_endpoint_matches(has_attribute(Clusters.ValveConfigurationAndControl.Attributes.LevelStep))
async def test_TC_VALCC_3_4(self):

endpoint = self.user_params.get("endpoint", 1)
endpoint = self.matter_test_config.endpoint

self.step(1)
attributes = Clusters.ValveConfigurationAndControl.Attributes

self.step(2)
attribute_list = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList)

self.step(3)
if attributes.LevelStep.attribute_id not in attribute_list:
logging.info("LevelStep not supported skipping test case")

# Skipping all remainig steps
for step in self.get_test_steps(self.current_test_info.name)[self.current_step_index:]:
self.step(step.test_plan_number)
logging.info("Test step skipped")

return

else:
logging.info("Test step skipped")
# Steps 2 and three are handled by the decorator

self.step(4)
levelStep = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.LevelStep)
Expand Down
Loading

0 comments on commit eb2dcbf

Please sign in to comment.