From 894057921620a826d6b3903292b86fb93380d17b Mon Sep 17 00:00:00 2001 From: Petru Lauric Date: Fri, 26 Jul 2024 19:45:13 -0400 Subject: [PATCH 01/15] initial commit --- src/python_testing/TC_SEAR_1_2.py | 384 ++++++++++++++++++++++++++++++ src/python_testing/TC_SEAR_1_3.py | 163 +++++++++++++ src/python_testing/TC_SEAR_1_4.py | 83 +++++++ src/python_testing/TC_SEAR_1_6.py | 155 ++++++++++++ 4 files changed, 785 insertions(+) create mode 100644 src/python_testing/TC_SEAR_1_2.py create mode 100644 src/python_testing/TC_SEAR_1_3.py create mode 100644 src/python_testing/TC_SEAR_1_4.py create mode 100644 src/python_testing/TC_SEAR_1_6.py diff --git a/src/python_testing/TC_SEAR_1_2.py b/src/python_testing/TC_SEAR_1_2.py new file mode 100644 index 00000000000000..f83ab82d38ab69 --- /dev/null +++ b/src/python_testing/TC_SEAR_1_2.py @@ -0,0 +1,384 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# TODO - this was copied/pasted from abother test, it needs to be reviewed and updated +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${CHIP_RVC_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# === END CI TEST ARGUMENTS === + +import logging +from time import sleep + +import chip.clusters as Clusters +from chip.clusters.Types import NullValue +from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_SEAR_1_2(MatterBaseTest): + def __init__(self, *args): + super().__init__(*args) + self.endpoint = None + self.is_ci = False + self.app_pipe = "/tmp/chip_rvc_fifo_" + self.mapid_list = [] + + #this must be kept in sync with the definitions from the Common Landmark Semantic Tag Namespace + self.MAX_LANDMARK_ID = 0x33 + + #this must be kept in sync with the definitions from the Common Relative Position Semantic Tag Namespace + self.MAX_RELPOS_ID = 0x07 + + + async def read_sear_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.ServiceArea + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + async def read_and_validate_supported_maps(self, step): + self.print_step(step, "Read SupportedMaps attribute") + supported_maps = await self.read_sear_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SupportedMaps) + logging.info("SupportedMaps: %s" % (supported_maps)) + asserts.assert_less_equal(len(supported_maps), 255, + "SupportedMaps should have max 255 entries") + mapid_list = [] + for m in supported_maps: + if m.mapID in mapid_list: + asserts.fail("SupportedMaps must have unique MapID values!") + else: + mapid_list.append(m.mapID) + name_list = [] + for m in supported_maps: + if m.name in name_list: + asserts.fail("SupportedMaps must have unique Name values!") + else: + name_list.append(m.name) + #save so other methods can use this if neeeded + self.mapid_list = mapid_list + + async def read_and_validate_supported_areas(self, step): + self.print_step(step, "Read SupportedAreas attribute") + supported_areas = await self.read_sear_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SupportedAreas) + logging.info("SupportedAreas: %s" % (supported_areas)) + asserts.assert_less_equal(len(supported_areas), 255, + "SupportedAreas should have max 255 entries") + areaid_list = [] + for a in supported_areas: + if a.areaID in areaid_list: + asserts.fail("SupportedAreas must have unique AreaID values!") + else: + areaid_list.append(a.areaID) + + if len(self.mapid_list) > 0: + asserts.assert_is_not(a.mapID, NullValue, + f"SupportedAreas entry with AreaID({a.areaID}) should not have null MapID") + asserts.assert_is(a.mapID in self.mapid_list, + f"SupportedAreas entry with AreaID({a.areaID}) has unknown MapID({a.mapID})") + areadesc_same_map_list = [] + areadesc_same_map_list.append(a.areaDesc) + for b in supported_areas: + if a.mapID == b.mapID: + if b.areaDesc in areadesc_same_map_list: + asserts.fail(f"SupportedAreas must have unique MapID({a.mapID}) + AreaDesc({a.areaDesc}) values!") + else: + areadesc_same_map_list.append(b.areaDesc) + else: + #empty SupportedMaps + asserts.assert_is(a.mapID, NullValue, + f"SupportedAreas entry with AreaID({a.areaID}) should have null MapID") + areadesc_list = [] + areadesc_list.append(a.areaDesc) + for b in supported_areas: + if b.areaDesc in areadesc_list: + asserts.fail(f"SupportedAreas must have unique AreaDesc({a.areaDesc}) values!") + else: + areadesc_list.append(b.areaDesc) + if a.locationInfo is NullValue and a.landmarkTag is NullValue: + asserts.assert_true(f"SupportedAreas entry with AreaID({a.areaID}) should not have null LocationInfo and null LandmarkTag") + if a.landmarkTag is not NullValue: + asserts.assert_true(a.landmarkTag in range(0, self.MAX_LANDMARK_ID), + f"SupportedAreas entry with AreaID({a.areaID}) has invalid LandmarkTag({a.landmarkTag})") + asserts.assert_true(a.positionTag is NullValue or a.positionTag in range(0, self.MAX_RELPOS_ID), + f"SupportedAreas entry with AreaID({a.areaID}) has invalid PositionTag({a.positionTag})") + #save so other methods can use this if neeeded + self.areaid_list = areaid_list + + async def read_and_validate_selected_areas(self, step): + self.print_step(step, "Read SelectedAreas attribute") + selected_areas = await self.read_sear_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SelectedAreas) + logging.info(f"SelectedAreas {selected_areas}") + + #TODO how to check if all entries are uint32? + + asserts.assert_true(len(selected_areas) <= len(self.areaid_list), + f"SelectedAreas(len {len(selected_areas)}) should have at most {len(self.areaid_list)} entries") + + selareaid_list = [] + for a in selected_areas: + if a.areaID in selareaid_list: + asserts.fail("SelectedAreas must have unique AreaID values!") + else: + selareaid_list.append(a.areaID) + asserts.assert_true(a.areaID in self.areaid_list, + f"SelectedAreas entry {a.areaID} has invalid value") + #save so other methods can use this if neeeded + self.selareaid_list = selareaid_list + + async def read_and_validate_current_area(self, step): + self.print_step(step, "Read CurrentArea attribute") + current_area = await self.read_sear_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.CurrentArea) + logging.info(f"CurrentArea {current_area}") + + asserts.assert_true((len(self.selareaid_list) == 0 and current_area is NullValue) + or + current_area in self.selareaid_list, + f"CurrentArea {current_area} is invalid. SelectedAreas is {self.selareaid_list}.") + #save so other methods can use this if neeeded + self.current_area = current_area + + async def read_and_validate_estimated_end_time(self, step): + import time + read_time = int(time.time()) + self.print_step(step, "Read EstimatedEndTime attribute") + estimated_end_time = await self.read_sear_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.EstimatedEndTime) + logging.info(f"EstimatedEndTime {estimated_end_time}") + + if self.current_area is NullValue: + asserts.assert_true(estimated_end_time is NullValue, + f"EstimatedEndTime should be null if CurrentArea is null.") + else: + #allow for some clock skew + asserts.assert_true(estimated_end_time >= read_time - 3*60, + f"EstimatedEndTime({estimated_end_time}) should be greater than the time when it was read({read_time})") + + + async def read_and_validate_progress(self, step): + self.print_step(step, "Read Progress attribute") + progress = await self.read_sear_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.Progress) + logging.info(f"Progress {progress}") + + asserts.assert_true(len(self.selected_areas) <= len(self.areaid_list), + f"Progress(len {len(progress)}) should have at most {len(self.areaid_list)} entries") + + progareaid_list = [] + for p in progress: + if p.areaID in progareaid_list: + asserts.fail("Progress must have unique AreaID values!") + else: + progareaid_list.append(p.areaID) + asserts.assert_true(p.areaID in self.areaid_list, + f"Progress entry has invalid AreaID value ({p.areaID})") + asserts.assert_true(p.status in (Clusters.ServiceArea.OperationalStatusEnum.kPending, + Clusters.ServiceArea.OperationalStatusEnum.kOperating, + Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + Clusters.ServiceArea.OperationalStatusEnum.kCompleted), + f"Progress entry has invalid Status value ({p.status})") + if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped, Clusters.ServiceArea.OperationalStatusEnum.kCompleted): + asserts.assert_true(p.totalOperationalTime is NullValue, + f"Progress entry should have a null TotalOperationalTime value (Status is {p.status})") + #TODO how to check that InitialTimeEstimate is either null or uint32? + + # Sends and out-of-band command to the rvc-app + def write_to_app_pipe(self, command): + with open(self.app_pipe, "w") as app_pipe: + app_pipe.write(command + "\n") + # Allow some time for the command to take effect. + # This removes the test flakyness which is very annoying for everyone in CI. + sleep(0.001) + + def TC_SEAR_1_2(self) -> list[str]: + return ["SEAR.S"] + + @async_test_body + async def test_TC_SEAR_1_2(self): + self.endpoint = self.matter_test_config.endpoint + asserts.assert_false(self.endpoint is None, "--endpoint must be included on the command line in.") + self.is_ci = self.check_pics("PICS_SDK_CI_ONLY") + if self.is_ci: + app_pid = self.matter_test_config.app_pid + if app_pid == 0: + asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set") + self.app_pipe = self.app_pipe + str(app_pid) + + self.print_step(1, "Commissioning, already done") + + # Ensure that the device is in the correct state + if self.is_ci: + self.write_to_app_pipe('{"Name": "Reset"}') + + if self.check_pics("SEAR.S.F02"): + await self.read_and_validate_supported_maps(2) + + await self.read_and_validate_supported_areas(3) + + await self.read_and_validate_selected_areas(4) + + if self.check_pics("SEAR.S.A0003"): + await self.read_and_validate_current_area(5) + + if self.check_pics("SEAR.S.A0004"): + await self.read_and_validate_estimated_end_time(6) + + if self.check_pics("SEAR.S.A0005"): + await self.read_and_validate_progress(7) + + if self.check_pics("SEAR.S.F02") and self.check_pics("SEAR.S.M.REMOVE_MAP"): + test_step = "Manually ensure the SupportedMaps attribute is not empty and that the device is not operating" + self.print_step("8", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + await self.read_and_validate_supported_maps(9) + old_supported_maps = self.mapid_list + + test_step = "Manually intervene to remove one or more entries in the SupportedMaps list" + self.print_step("10", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + await self.read_and_validate_supported_maps(11) + new_supported_maps = self.mapid_list + asserts.assert_true(len(old_supported_maps > len(new_supported_maps)), f"Failed to remove map(s)") + + #NOTE the following operations are all part of step 11 - read all these attributes and check the data consistency + # after removing map(s) + await self.read_and_validate_supported_areas(11) + + await self.read_and_validate_selected_areas(11) + + if self.check_pics("SEAR.S.A0003"): + await self.read_and_validate_current_area(11) + + if self.check_pics("SEAR.S.A0004"): + await self.read_and_validate_estimated_end_time(11) + + if self.check_pics("SEAR.S.A0005"): + await self.read_and_validate_progress(11) + + if self.check_pics("SEAR.S.F02") and self.check_pics("SEAR.S.M.ADD_MAP"): + test_step = "Manually ensure the SupportedMaps attribute has less than 255 entries and that the device is not operating" + self.print_step("12", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + await self.read_and_validate_supported_maps(13) + old_supported_maps = self.mapid_list + + test_step = "Manually intervene to add one or more entries to the SupportedMaps list" + self.print_step("14", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + await self.read_and_validate_supported_maps(15) + new_supported_maps = self.mapid_list + asserts.assert_true(len(old_supported_maps < len(new_supported_maps)), f"Failed to add map(s)") + + #NOTE the following operations are all part of step 15 - read all these attributes and check the data consistency + # after adding map(s) + await self.read_and_validate_supported_areas(15) + + await self.read_and_validate_selected_areas(15) + + if self.check_pics("SEAR.S.A0003"): + await self.read_and_validate_current_area(15) + + if self.check_pics("SEAR.S.A0004"): + await self.read_and_validate_estimated_end_time(15) + + if self.check_pics("SEAR.S.A0005"): + await self.read_and_validate_progress(15) + + if self.check_pics("SEAR.S.M.REMOVE_AREA"): + test_step = "Manually ensure the SupportedAreas attribute is not empty and that the device is not operating" + self.print_step("16", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + await self.read_and_validate_supported_areas(17) + old_supported_areas = self.areaid_list + + test_step = "Manually intervene to remove one or more entries from the SupportedAreas list" + self.print_step("18", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + await self.read_and_validate_supported_areas(19) + new_supported_areas = self.areaid_list + asserts.assert_true(len(old_supported_areas > len(new_supported_areas)), f"Failed to remove area(s)") + + #NOTE the following operations are all part of step 19 - read all these attributes and check the data consistency + # after removing areas(s) + + await self.read_and_validate_selected_areas(19) + + if self.check_pics("SEAR.S.A0003"): + await self.read_and_validate_current_area(19) + + if self.check_pics("SEAR.S.A0004"): + await self.read_and_validate_estimated_end_time(19) + + if self.check_pics("SEAR.S.A0005"): + await self.read_and_validate_progress(19) + + if self.check_pics("SEAR.S.M.ADD_AREA"): + test_step = "Manually ensure the SupportedAreas attribute has less than 255 entries and that the device is not operating" + self.print_step("20", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + await self.read_and_validate_supported_areas(21) + old_supported_areas = self.areaid_list + + test_step = "Manually intervene to add one or more entries to the SupportedAreas list" + self.print_step("22", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + await self.read_and_validate_supported_areas(23) + new_supported_areas = self.areaid_list + asserts.assert_true(len(old_supported_areas < len(new_supported_areas)), f"Failed to add area(s)") + + #NOTE the following operations are all part of step 23 - read all these attributes and check the data consistency + # after removing areas(s) + + await self.read_and_validate_selected_areas(23) + + if self.check_pics("SEAR.S.A0003"): + await self.read_and_validate_current_area(23) + + if self.check_pics("SEAR.S.A0004"): + await self.read_and_validate_estimated_end_time(23) + + if self.check_pics("SEAR.S.A0005"): + await self.read_and_validate_progress(23) + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_SEAR_1_3.py b/src/python_testing/TC_SEAR_1_3.py new file mode 100644 index 00000000000000..bdc133f1fa7103 --- /dev/null +++ b/src/python_testing/TC_SEAR_1_3.py @@ -0,0 +1,163 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# TODO - this was copied/pasted from abother test, it needs to be reviewed and updated +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${CHIP_RVC_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# === END CI TEST ARGUMENTS === + +import logging +from time import sleep + +import chip.clusters as Clusters +from chip.clusters.Types import NullValue +from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_SEAR_1_3(MatterBaseTest): + def __init__(self, *args): + super().__init__(*args) + self.endpoint = None + self.is_ci = False + self.app_pipe = "/tmp/chip_rvc_fifo_" + + async def read_sear_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.ServiceArea + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + async def read_supported_areas(self, step): + self.print_step(step, "Read SupportedAreas attribute") + supported_areas = await self.read_sear_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SupportedAreas) + logging.info("SupportedAreas: %s" % (supported_areas)) + + areaid_list = [] + for a in supported_areas: + areaid_list.append(a.areaID) + return areaid_list + + async def read_selected_areas(self, step): + self.print_step(step, "Read SelectedAreas attribute") + selected_areas = await self.read_sear_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SelectedAreas) + logging.info(f"SelectedAreas {selected_areas}") + + selareaid_list = [] + for a in selected_areas: + selareaid_list.append(a.areaID) + return selareaid_list + + + async def send_cmd_select_areas_expect_response(self, step, new_areas, expected_response): + self.print_step(step, f"Send SelectAreas command with NewAreas({new_areas})") + ret = await self.send_single_cmd(cmd=Clusters.Objects.ServiceArea.Commands.SelectAreas(newAreas=new_areas), + endpoint=self.endpoint) + + asserts.assert_equal(ret.commandResponseState.errorStateID, + expected_response, + f"Command response ({ret.commandResponseState}) doesn't match the expected one") + + # Sends and out-of-band command to the rvc-app + def write_to_app_pipe(self, command): + with open(self.app_pipe, "w") as app_pipe: + app_pipe.write(command + "\n") + # Allow some time for the command to take effect. + # This removes the test flakyness which is very annoying for everyone in CI. + sleep(0.001) + + def TC_SEAR_1_3(self) -> list[str]: + return ["SEAR.S"] + + @async_test_body + async def test_TC_SEAR_1_3(self): + self.endpoint = self.matter_test_config.endpoint + asserts.assert_false(self.endpoint is None, "--endpoint must be included on the command line in.") + self.is_ci = self.check_pics("PICS_SDK_CI_ONLY") + if self.is_ci: + app_pid = self.matter_test_config.app_pid + if app_pid == 0: + asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set") + self.app_pipe = self.app_pipe + str(app_pid) + + self.print_step(1, "Commissioning, already done") + + # Ensure that the device is in the correct state + if self.is_ci: + self.write_to_app_pipe('{"Name": "Reset"}') + + supported_area_ids = await self.read_supported_areas(2) + asserts.assert_true(len(self.supported_areas > 0), f"SupportedAreas is empty") + valid_area_id = supported_area_ids[0] + invalid_area_id = 1 + max(supported_area_ids) + + duplicated_areas = [valid_area_id, valid_area_id] + + #FIXME need to check if this is the correct name of this status code + await self.send_cmd_select_areas_expect_response(3, duplicated_areas, Clusters.ServiceArea.SelectAreasStatus.kDuplicatedAreas) + + await self.send_cmd_select_areas_expect_response(4, [], Clusters.ServiceArea.SelectAreasStatus.kSuccess) + + selected_areas = await self.read_selected_areas(5) + asserts.assert_true(len(selected_areas == 0), f"SelectedAreas should be empty") + + await self.send_cmd_select_areas_expect_response(6, [invalid_area_id], Clusters.ServiceArea.SelectAreasStatus.kUnsupportedArea) + + if self.check_pics("SEAR.S.M.INVALID_STATE_FOR_SELECT_AREAS") and self.check_pics("SEAR.S.M.HAS_MANUAL_SELAREA_STATE_CONTROL"): + test_step = "Manually intervene to put the device in a state that prevents it from executing the SelectAreas command" + self.print_step("7", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + await self.send_cmd_select_areas_expect_response(8, [valid_area_id], Clusters.ServiceArea.SelectAreasStatus.kInvalidInMode) + + if self.check_pics("SEAR.S.M.VALID_STATE_FOR_SELECT_AREAS") and self.check_pics("SEAR.S.M.HAS_MANUAL_SELAREA_STATE_CONTROL"): + test_step = f"Manually intervene to put the device in a state that allows it to execute the SelectAreas({supported_area_ids}) command" + self.print_step("9", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + await self.send_cmd_select_areas_expect_response(10, supported_area_ids, Clusters.ServiceArea.SelectAreasStatus.kSuccess) + + selected_areas = await self.read_selected_areas(11) + asserts.assert_true(len(selected_areas == supported_area_ids), f"SelectedAreas({selected_areas}) should match SupportedAreas({supported_area_ids})") + + await self.send_cmd_select_areas_expect_response(12, supported_area_ids, Clusters.ServiceArea.SelectAreasStatus.kSuccess) + + if self.check_pics("SEAR.S.M.VALID_STATE_FOR_SELECT_AREAS") and self.check_pics("SEAR.S.M.HAS_MANUAL_SELAREA_STATE_CONTROL") and self.check_pics("SEAR.S.M.SELECT_AREAS_WHILE_NON_IDLE"): + test_step = f"Manually intervene to put the device in a state that allows it to execute the SelectAreas({valid_area_id}) command, and put the device in a non-idle state" + self.print_step("13", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + if self.check_pics("SEAR.S.F00"): + await self.send_cmd_select_areas_expect_response(14, [valid_area_id], Clusters.ServiceArea.SelectAreasStatus.kSuccess) + else: + await self.send_cmd_select_areas_expect_response(14, [valid_area_id], Clusters.ServiceArea.SelectAreasStatus.kInvalidInMode) + + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_SEAR_1_4.py b/src/python_testing/TC_SEAR_1_4.py new file mode 100644 index 00000000000000..6f30423969618e --- /dev/null +++ b/src/python_testing/TC_SEAR_1_4.py @@ -0,0 +1,83 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# TODO - this was copied/pasted from abother test, it needs to be reviewed and updated +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${CHIP_RVC_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# === END CI TEST ARGUMENTS === + +import logging +from time import sleep + +import chip.clusters as Clusters +from chip.clusters.Types import NullValue +from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_SEAR_1_4(MatterBaseTest): + def __init__(self, *args): + super().__init__(*args) + self.endpoint = None + self.is_ci = False + self.app_pipe = "/tmp/chip_rvc_fifo_" + + async def read_sear_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.ServiceArea + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def TC_SEAR_1_4(self) -> list[str]: + return ["SEAR.S"] + + @async_test_body + async def test_TC_SEAR_1_4(self): + self.endpoint = self.matter_test_config.endpoint + asserts.assert_false(self.endpoint is None, "--endpoint must be included on the command line in.") + self.is_ci = self.check_pics("PICS_SDK_CI_ONLY") + if self.is_ci: + app_pid = self.matter_test_config.app_pid + if app_pid == 0: + asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set") + self.app_pipe = self.app_pipe + str(app_pid) + + self.print_step(1, "Commissioning, already done") + + # Ensure that the device is in the correct state + if self.is_ci: + self.write_to_app_pipe('{"Name": "Reset"}') + + attribute_list = await self.read_sear_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.AttributeList) + logging.info("AttributeList: %s" % (attribute_list)) + + if not (Clusters.ServiceArea.Attributes.CurrentArea in attribute_list and Clusters.ServiceArea.Attributes.Progress in attribute_list): + cmd_list = await self.read_sear_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.AcceptedCommandList) + logging.info("AcceptedCommandList: %s" % (cmd_list)) + asserts.assert_true(Clusters.ServiceArea.Commands.SkipArea not in cmd_list, f"SkipArea command should not be implemented if both CurrentArea and Progress are not") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_SEAR_1_6.py b/src/python_testing/TC_SEAR_1_6.py new file mode 100644 index 00000000000000..b3c2c117474949 --- /dev/null +++ b/src/python_testing/TC_SEAR_1_6.py @@ -0,0 +1,155 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# TODO - this was copied/pasted from abother test, it needs to be reviewed and updated +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${CHIP_RVC_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# === END CI TEST ARGUMENTS === + +import logging +from time import sleep + +import chip.clusters as Clusters +from chip.clusters.Types import NullValue +from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main +from mobly import asserts + +class TC_SEAR_1_6(MatterBaseTest): + def __init__(self, *args): + super().__init__(*args) + self.endpoint = None + self.is_ci = False + self.app_pipe = "/tmp/chip_rvc_fifo_" + + async def read_sear_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.ServiceArea + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + async def read_supported_areas(self, step): + self.print_step(step, "Read SupportedAreas attribute") + supported_areas = await self.read_sear_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SupportedAreas) + logging.info("SupportedAreas: %s" % (supported_areas)) + + areaid_list = [] + for a in supported_areas: + areaid_list.append(a.areaID) + return areaid_list + + async def read_selected_areas(self, step): + self.print_step(step, "Read SelectedAreas attribute") + selected_areas = await self.read_sear_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SelectedAreas) + logging.info(f"SelectedAreas {selected_areas}") + + selareaid_list = [] + for a in selected_areas: + selareaid_list.append(a.areaID) + return selareaid_list + + async def read_progress(self, step): + self.print_step(step, "Read Progress attribute") + progress = await self.read_sear_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.Progress) + logging.info(f"Progress {progress}") + + return progress + + # Sends and out-of-band command to the rvc-app + def write_to_app_pipe(self, command): + with open(self.app_pipe, "w") as app_pipe: + app_pipe.write(command + "\n") + # Allow some time for the command to take effect. + # This removes the test flakyness which is very annoying for everyone in CI. + sleep(0.001) + + def TC_SEAR_1_6(self) -> list[str]: + return ["SEAR.S", "SEAR.S.A0005", "SEAR.S.M.HAS_MANUAL_OPERATING_STATE_CONTROL"] + + @async_test_body + async def test_TC_SEAR_1_6(self): + self.endpoint = self.matter_test_config.endpoint + asserts.assert_false(self.endpoint is None, "--endpoint must be included on the command line in.") + self.is_ci = self.check_pics("PICS_SDK_CI_ONLY") + if self.is_ci: + app_pid = self.matter_test_config.app_pid + if app_pid == 0: + asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set") + self.app_pipe = self.app_pipe + str(app_pid) + + self.print_step(1, "Commissioning, already done") + + # Ensure that the device is in the correct state + if self.is_ci: + self.write_to_app_pipe('{"Name": "Reset"}') + + #FIXME is this necesssary? I'm not sure what TC_SEAR_1_6() is used for + if not (self.check_pics("SEAR.S.A0005") and self.check_pics("SEAR.S.M.HAS_MANUAL_OPERATING_STATE_CONTROL")): + return + + test_step = "Manually intervene to put the device in the idle state and ensure SupportedAreas and SelectedAreas are not empty" + self.print_step("2", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + supported_area_ids = await self.read_supported_areas(3) + asserts.assert_true(len(supported_area_ids) > 0, f"SupportedAreas is empty") + + selected_areas = await self.read_selected_areas(4) + asserts.assert_true(len(selected_areas) > 0, f"SelectedAreas is empty") + + test_step = "Manually intervene to put the device in the operating state" + self.print_step("5", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + progress_list_operating = await self.read_progress(6) + asserts.assert_true(len(selected_areas) == len(progress_list_operating), f"len of SelectedAreas({len(selected_areas)}) should be equal to len of Progress({len(progress_list_operating)})") + + for p in progress_list_operating: + asserts.assert_true(p.areaID in selected_areas, f"Progress entry with unknown AreaID({p.areaID})") + asserts.assert_true(p.status in (Clusters.ServiceArea.OperationalStatusEnum.kPending, + Clusters.ServiceArea.OperationalStatusEnum.kOperating), + f"Progress entry with unexpected Status({p.status})") + asserts.assert_true(p.TotalOperationalTime is NullValue, f"Progress entry with non-null TotalOperationalTime") + + test_step = "While all entries in Progress show the Pending or Operating status (i.e. \ + before any area is skipped or completed), manually intervene to put the device \ + in the idle state, by ending the operation unexpectedly (e.g. force an error)" + self.print_step("7", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + progress_list_idle = await self.read_progress(8) + asserts.assert_true(len(selected_areas) == len(progress_list_idle), f"len of SelectedAreas({len(selected_areas)}) should be equal to len of Progress({len(progress_list_idle)})") + + for p in progress_list_idle: + asserts.assert_true(p.areaID in selected_areas, f"Progress entry with unknown AreaID({p.areaID})") + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + f"Progress entry with unexpected Status({p.status})") + + +if __name__ == "__main__": + default_matter_test_main() From bfb6629f1343efb13a7a39c721c95c14969d688d Mon Sep 17 00:00:00 2001 From: Petru Lauric Date: Fri, 26 Jul 2024 19:58:21 -0400 Subject: [PATCH 02/15] fix bugs --- src/python_testing/TC_SEAR_1_2.py | 8 ++++---- src/python_testing/TC_SEAR_1_3.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/python_testing/TC_SEAR_1_2.py b/src/python_testing/TC_SEAR_1_2.py index f83ab82d38ab69..902bcff267dbd5 100644 --- a/src/python_testing/TC_SEAR_1_2.py +++ b/src/python_testing/TC_SEAR_1_2.py @@ -265,7 +265,7 @@ async def test_TC_SEAR_1_2(self): await self.read_and_validate_supported_maps(11) new_supported_maps = self.mapid_list - asserts.assert_true(len(old_supported_maps > len(new_supported_maps)), f"Failed to remove map(s)") + asserts.assert_true(len(old_supported_maps) > len(new_supported_maps), f"Failed to remove map(s)") #NOTE the following operations are all part of step 11 - read all these attributes and check the data consistency # after removing map(s) @@ -298,7 +298,7 @@ async def test_TC_SEAR_1_2(self): await self.read_and_validate_supported_maps(15) new_supported_maps = self.mapid_list - asserts.assert_true(len(old_supported_maps < len(new_supported_maps)), f"Failed to add map(s)") + asserts.assert_true(len(old_supported_maps) < len(new_supported_maps), f"Failed to add map(s)") #NOTE the following operations are all part of step 15 - read all these attributes and check the data consistency # after adding map(s) @@ -331,7 +331,7 @@ async def test_TC_SEAR_1_2(self): await self.read_and_validate_supported_areas(19) new_supported_areas = self.areaid_list - asserts.assert_true(len(old_supported_areas > len(new_supported_areas)), f"Failed to remove area(s)") + asserts.assert_true(len(old_supported_areas) > len(new_supported_areas), f"Failed to remove area(s)") #NOTE the following operations are all part of step 19 - read all these attributes and check the data consistency # after removing areas(s) @@ -363,7 +363,7 @@ async def test_TC_SEAR_1_2(self): await self.read_and_validate_supported_areas(23) new_supported_areas = self.areaid_list - asserts.assert_true(len(old_supported_areas < len(new_supported_areas)), f"Failed to add area(s)") + asserts.assert_true(len(old_supported_areas) < len(new_supported_areas), f"Failed to add area(s)") #NOTE the following operations are all part of step 23 - read all these attributes and check the data consistency # after removing areas(s) diff --git a/src/python_testing/TC_SEAR_1_3.py b/src/python_testing/TC_SEAR_1_3.py index bdc133f1fa7103..9168f8768fab34 100644 --- a/src/python_testing/TC_SEAR_1_3.py +++ b/src/python_testing/TC_SEAR_1_3.py @@ -109,7 +109,7 @@ async def test_TC_SEAR_1_3(self): self.write_to_app_pipe('{"Name": "Reset"}') supported_area_ids = await self.read_supported_areas(2) - asserts.assert_true(len(self.supported_areas > 0), f"SupportedAreas is empty") + asserts.assert_true(len(self.supported_areas) > 0, f"SupportedAreas is empty") valid_area_id = supported_area_ids[0] invalid_area_id = 1 + max(supported_area_ids) @@ -121,7 +121,7 @@ async def test_TC_SEAR_1_3(self): await self.send_cmd_select_areas_expect_response(4, [], Clusters.ServiceArea.SelectAreasStatus.kSuccess) selected_areas = await self.read_selected_areas(5) - asserts.assert_true(len(selected_areas == 0), f"SelectedAreas should be empty") + asserts.assert_true(len(selected_areas) == 0, f"SelectedAreas should be empty") await self.send_cmd_select_areas_expect_response(6, [invalid_area_id], Clusters.ServiceArea.SelectAreasStatus.kUnsupportedArea) @@ -142,7 +142,7 @@ async def test_TC_SEAR_1_3(self): await self.send_cmd_select_areas_expect_response(10, supported_area_ids, Clusters.ServiceArea.SelectAreasStatus.kSuccess) selected_areas = await self.read_selected_areas(11) - asserts.assert_true(len(selected_areas == supported_area_ids), f"SelectedAreas({selected_areas}) should match SupportedAreas({supported_area_ids})") + asserts.assert_true(len(selected_areas) == len(supported_area_ids), f"SelectedAreas({selected_areas}) should match SupportedAreas({supported_area_ids})") await self.send_cmd_select_areas_expect_response(12, supported_area_ids, Clusters.ServiceArea.SelectAreasStatus.kSuccess) From 91c9d5b73faabee952bb0c4b2cdb3164f28ea88c Mon Sep 17 00:00:00 2001 From: Petru Lauric Date: Fri, 26 Jul 2024 22:44:39 -0400 Subject: [PATCH 03/15] fix issues reported by the linter --- src/python_testing/TC_SEAR_1_2.py | 10 +++++----- src/python_testing/TC_SEAR_1_3.py | 5 ++--- src/python_testing/TC_SEAR_1_4.py | 4 +--- src/python_testing/TC_SEAR_1_6.py | 6 +++--- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/python_testing/TC_SEAR_1_2.py b/src/python_testing/TC_SEAR_1_2.py index 902bcff267dbd5..e46633723488c1 100644 --- a/src/python_testing/TC_SEAR_1_2.py +++ b/src/python_testing/TC_SEAR_1_2.py @@ -171,7 +171,7 @@ async def read_and_validate_estimated_end_time(self, step): if self.current_area is NullValue: asserts.assert_true(estimated_end_time is NullValue, - f"EstimatedEndTime should be null if CurrentArea is null.") + "EstimatedEndTime should be null if CurrentArea is null.") else: #allow for some clock skew asserts.assert_true(estimated_end_time >= read_time - 3*60, @@ -265,7 +265,7 @@ async def test_TC_SEAR_1_2(self): await self.read_and_validate_supported_maps(11) new_supported_maps = self.mapid_list - asserts.assert_true(len(old_supported_maps) > len(new_supported_maps), f"Failed to remove map(s)") + asserts.assert_true(len(old_supported_maps) > len(new_supported_maps), "Failed to remove map(s)") #NOTE the following operations are all part of step 11 - read all these attributes and check the data consistency # after removing map(s) @@ -298,7 +298,7 @@ async def test_TC_SEAR_1_2(self): await self.read_and_validate_supported_maps(15) new_supported_maps = self.mapid_list - asserts.assert_true(len(old_supported_maps) < len(new_supported_maps), f"Failed to add map(s)") + asserts.assert_true(len(old_supported_maps) < len(new_supported_maps), "Failed to add map(s)") #NOTE the following operations are all part of step 15 - read all these attributes and check the data consistency # after adding map(s) @@ -331,7 +331,7 @@ async def test_TC_SEAR_1_2(self): await self.read_and_validate_supported_areas(19) new_supported_areas = self.areaid_list - asserts.assert_true(len(old_supported_areas) > len(new_supported_areas), f"Failed to remove area(s)") + asserts.assert_true(len(old_supported_areas) > len(new_supported_areas), "Failed to remove area(s)") #NOTE the following operations are all part of step 19 - read all these attributes and check the data consistency # after removing areas(s) @@ -363,7 +363,7 @@ async def test_TC_SEAR_1_2(self): await self.read_and_validate_supported_areas(23) new_supported_areas = self.areaid_list - asserts.assert_true(len(old_supported_areas) < len(new_supported_areas), f"Failed to add area(s)") + asserts.assert_true(len(old_supported_areas) < len(new_supported_areas), "Failed to add area(s)") #NOTE the following operations are all part of step 23 - read all these attributes and check the data consistency # after removing areas(s) diff --git a/src/python_testing/TC_SEAR_1_3.py b/src/python_testing/TC_SEAR_1_3.py index 9168f8768fab34..db2204970e1da4 100644 --- a/src/python_testing/TC_SEAR_1_3.py +++ b/src/python_testing/TC_SEAR_1_3.py @@ -32,7 +32,6 @@ from time import sleep import chip.clusters as Clusters -from chip.clusters.Types import NullValue from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main from mobly import asserts @@ -109,7 +108,7 @@ async def test_TC_SEAR_1_3(self): self.write_to_app_pipe('{"Name": "Reset"}') supported_area_ids = await self.read_supported_areas(2) - asserts.assert_true(len(self.supported_areas) > 0, f"SupportedAreas is empty") + asserts.assert_true(len(self.supported_areas) > 0, "SupportedAreas is empty") valid_area_id = supported_area_ids[0] invalid_area_id = 1 + max(supported_area_ids) @@ -121,7 +120,7 @@ async def test_TC_SEAR_1_3(self): await self.send_cmd_select_areas_expect_response(4, [], Clusters.ServiceArea.SelectAreasStatus.kSuccess) selected_areas = await self.read_selected_areas(5) - asserts.assert_true(len(selected_areas) == 0, f"SelectedAreas should be empty") + asserts.assert_true(len(selected_areas) == 0, "SelectedAreas should be empty") await self.send_cmd_select_areas_expect_response(6, [invalid_area_id], Clusters.ServiceArea.SelectAreasStatus.kUnsupportedArea) diff --git a/src/python_testing/TC_SEAR_1_4.py b/src/python_testing/TC_SEAR_1_4.py index 6f30423969618e..6c56d9ae9b6c8b 100644 --- a/src/python_testing/TC_SEAR_1_4.py +++ b/src/python_testing/TC_SEAR_1_4.py @@ -29,10 +29,8 @@ # === END CI TEST ARGUMENTS === import logging -from time import sleep import chip.clusters as Clusters -from chip.clusters.Types import NullValue from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main from mobly import asserts @@ -76,7 +74,7 @@ async def test_TC_SEAR_1_4(self): cmd_list = await self.read_sear_attribute_expect_success( endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.AcceptedCommandList) logging.info("AcceptedCommandList: %s" % (cmd_list)) - asserts.assert_true(Clusters.ServiceArea.Commands.SkipArea not in cmd_list, f"SkipArea command should not be implemented if both CurrentArea and Progress are not") + asserts.assert_true(Clusters.ServiceArea.Commands.SkipArea not in cmd_list, "SkipArea command should not be implemented if both CurrentArea and Progress are not") if __name__ == "__main__": diff --git a/src/python_testing/TC_SEAR_1_6.py b/src/python_testing/TC_SEAR_1_6.py index b3c2c117474949..6398215cf8b122 100644 --- a/src/python_testing/TC_SEAR_1_6.py +++ b/src/python_testing/TC_SEAR_1_6.py @@ -115,10 +115,10 @@ async def test_TC_SEAR_1_6(self): self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") supported_area_ids = await self.read_supported_areas(3) - asserts.assert_true(len(supported_area_ids) > 0, f"SupportedAreas is empty") + asserts.assert_true(len(supported_area_ids) > 0, "SupportedAreas is empty") selected_areas = await self.read_selected_areas(4) - asserts.assert_true(len(selected_areas) > 0, f"SelectedAreas is empty") + asserts.assert_true(len(selected_areas) > 0, "SelectedAreas is empty") test_step = "Manually intervene to put the device in the operating state" self.print_step("5", test_step) @@ -133,7 +133,7 @@ async def test_TC_SEAR_1_6(self): asserts.assert_true(p.status in (Clusters.ServiceArea.OperationalStatusEnum.kPending, Clusters.ServiceArea.OperationalStatusEnum.kOperating), f"Progress entry with unexpected Status({p.status})") - asserts.assert_true(p.TotalOperationalTime is NullValue, f"Progress entry with non-null TotalOperationalTime") + asserts.assert_true(p.TotalOperationalTime is NullValue, "Progress entry with non-null TotalOperationalTime") test_step = "While all entries in Progress show the Pending or Operating status (i.e. \ before any area is skipped or completed), manually intervene to put the device \ From 73a641fb1b74a8631d614ac42e1f050f80471acb Mon Sep 17 00:00:00 2001 From: Petru Lauric Date: Mon, 29 Jul 2024 11:29:15 -0400 Subject: [PATCH 04/15] fix bug in checking for unique areaDesc --- src/python_testing/TC_SEAR_1_2.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/python_testing/TC_SEAR_1_2.py b/src/python_testing/TC_SEAR_1_2.py index e46633723488c1..993276533cd2d2 100644 --- a/src/python_testing/TC_SEAR_1_2.py +++ b/src/python_testing/TC_SEAR_1_2.py @@ -86,6 +86,7 @@ async def read_and_validate_supported_areas(self, step): asserts.assert_less_equal(len(supported_areas), 255, "SupportedAreas should have max 255 entries") areaid_list = [] + areadesc_s = set() for a in supported_areas: if a.areaID in areaid_list: asserts.fail("SupportedAreas must have unique AreaID values!") @@ -97,25 +98,17 @@ async def read_and_validate_supported_areas(self, step): f"SupportedAreas entry with AreaID({a.areaID}) should not have null MapID") asserts.assert_is(a.mapID in self.mapid_list, f"SupportedAreas entry with AreaID({a.areaID}) has unknown MapID({a.mapID})") - areadesc_same_map_list = [] - areadesc_same_map_list.append(a.areaDesc) - for b in supported_areas: - if a.mapID == b.mapID: - if b.areaDesc in areadesc_same_map_list: - asserts.fail(f"SupportedAreas must have unique MapID({a.mapID}) + AreaDesc({a.areaDesc}) values!") - else: - areadesc_same_map_list.append(b.areaDesc) + k = f"mapID:{a.mapID} areaDesc:{a.areaDesc}" + asserts.true(k not in areadesc_s, f"SupportedAreas must have unique MapID({a.mapID}) + AreaDesc({a.areaDesc}) values!") + areadesc_s.add(k) else: #empty SupportedMaps asserts.assert_is(a.mapID, NullValue, f"SupportedAreas entry with AreaID({a.areaID}) should have null MapID") - areadesc_list = [] - areadesc_list.append(a.areaDesc) - for b in supported_areas: - if b.areaDesc in areadesc_list: - asserts.fail(f"SupportedAreas must have unique AreaDesc({a.areaDesc}) values!") - else: - areadesc_list.append(b.areaDesc) + k = f"areaDesc:{a.areaDesc}" + asserts.true(k not in areadesc_s, f"SupportedAreas must have unique AreaDesc({a.areaDesc}) values!") + areadesc_s.add(k) + if a.locationInfo is NullValue and a.landmarkTag is NullValue: asserts.assert_true(f"SupportedAreas entry with AreaID({a.areaID}) should not have null LocationInfo and null LandmarkTag") if a.landmarkTag is not NullValue: From fac4db26eaa8068fd59e2ee9039dcaa73e6d9df5 Mon Sep 17 00:00:00 2001 From: Petru Lauric Date: Mon, 29 Jul 2024 13:05:03 -0400 Subject: [PATCH 05/15] add TC 1.5 --- src/python_testing/TC_SEAR_1_5.py | 274 ++++++++++++++++++++++++++++++ 1 file changed, 274 insertions(+) create mode 100644 src/python_testing/TC_SEAR_1_5.py diff --git a/src/python_testing/TC_SEAR_1_5.py b/src/python_testing/TC_SEAR_1_5.py new file mode 100644 index 00000000000000..0315532d97b204 --- /dev/null +++ b/src/python_testing/TC_SEAR_1_5.py @@ -0,0 +1,274 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# TODO - this was copied/pasted from abother test, it needs to be reviewed and updated +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${CHIP_RVC_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# === END CI TEST ARGUMENTS === + +import logging +from time import sleep + +import chip.clusters as Clusters +from chip.clusters.Types import NullValue +from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main +from mobly import asserts + +class TC_SEAR_1_5(MatterBaseTest): + def __init__(self, *args): + super().__init__(*args) + self.endpoint = None + self.is_ci = False + self.app_pipe = "/tmp/chip_rvc_fifo_" + + async def read_sear_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.ServiceArea + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + async def read_supported_areas(self, step): + self.print_step(step, "Read SupportedAreas attribute") + supported_areas = await self.read_sear_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SupportedAreas) + logging.info("SupportedAreas: %s" % (supported_areas)) + + areaid_list = [] + for a in supported_areas: + areaid_list.append(a.areaID) + return areaid_list + + async def read_selected_areas(self, step): + self.print_step(step, "Read SelectedAreas attribute") + selected_areas = await self.read_sear_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SelectedAreas) + logging.info(f"SelectedAreas {selected_areas}") + + selareaid_list = [] + for a in selected_areas: + selareaid_list.append(a.areaID) + return selareaid_list + + async def read_progress(self, step): + self.print_step(step, "Read Progress attribute") + progress = await self.read_sear_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.Progress) + logging.info(f"Progress {progress}") + + return progress + + async def read_current_area(self, step): + self.print_step(step, "Read CurrentArea attribute") + current_area = await self.read_sear_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.CurrentArea) + logging.info(f"CurrentArea {current_area}") + + return current_area + + async def send_cmd_skip_area_expect_response(self, step, skipped_area, expected_response): + self.print_step(step, f"Send SkipArea command with SkippedArea({skipped_area})") + ret = await self.send_single_cmd(cmd=Clusters.Objects.ServiceArea.Commands.SkipArea(skippedArea=skipped_area), + endpoint=self.endpoint) + + asserts.assert_equal(ret.commandResponseState.errorStateID, + expected_response, + f"Command response ({ret.commandResponseState}) doesn't match the expected one") + + + # Sends and out-of-band command to the rvc-app + def write_to_app_pipe(self, command): + with open(self.app_pipe, "w") as app_pipe: + app_pipe.write(command + "\n") + # Allow some time for the command to take effect. + # This removes the test flakyness which is very annoying for everyone in CI. + sleep(0.001) + + def TC_SEAR_1_5(self) -> list[str]: + return ["SEAR.S", "SEAR.S.A0005", "SEAR.S.M.HAS_MANUAL_OPERATING_STATE_CONTROL"] + + @async_test_body + async def test_TC_SEAR_1_5(self): + self.endpoint = self.matter_test_config.endpoint + asserts.assert_false(self.endpoint is None, "--endpoint must be included on the command line in.") + self.is_ci = self.check_pics("PICS_SDK_CI_ONLY") + if self.is_ci: + app_pid = self.matter_test_config.app_pid + if app_pid == 0: + asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set") + self.app_pipe = self.app_pipe + str(app_pid) + + self.print_step(1, "Commissioning, already done") + + # Ensure that the device is in the correct state + if self.is_ci: + self.write_to_app_pipe('{"Name": "Reset"}') + + supported_area_ids = await self.read_supported_areas(2) + asserts.assert_true(len(supported_area_ids) > 0, "SupportedAreas is empty") + valid_area_id = supported_area_ids[0] + invalid_area_id = 1 + max(supported_area_ids) + + if self.check_pics("SEAR.S.M.INVALID_STATE_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): + test_step = "Manually intervene to put the device in a state that prevents it from executing the SkipArea command \ + (e.g. set CurrentArea to null or make it not operate, i.e. be in the idle state)" + self.print_step("3", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + await self.send_cmd_skip_area_expect_response(4, valid_area_id, Clusters.ServiceArea.SkipAreaStatus.kInvalidInMode) + + if self.check_pics("SEAR.S.M.NO_SELAREA_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): + test_step = "Manually intervene to put the device in a state where the state would allow it to execute the SkipArea command, \ + if SelectedAreas wasn't empty, and SelectedAreas is empty" + self.print_step("5", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + await self.send_cmd_skip_area_expect_response(6, valid_area_id, Clusters.ServiceArea.SkipAreaStatus.kInvalidAreaList) + + if self.check_pics("SEAR.S.M.VALID_STATE_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): + test_step = "Manually intervene to put the device in a state that allows it to execute the SkipArea command" + self.print_step("7", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + await self.send_cmd_skip_area_expect_response(8, invalid_area_id, Clusters.ServiceArea.SkipAreaStatus.kInvalidSkippedArea) + + if self.check_pics("SEAR.S.A0005"): + old_progress_list = await self.read_progress(9) + asserts.assert_true(len(old_progress_list) > 0, f"len of Progress({len(old_progress_list)}) should not be zero)") + + selected_areas = await self.read_selected_areas(10) + asserts.assert_true(len(selected_areas) > 0, "SelectedAreas is empty") + + old_current_area = NullValue + if self.check_pics("SEAR.S.A0003"): + old_current_area = await self.read_current_area(11) + + self.print_step("12", "") + if old_current_area is not NullValue: + await self.send_cmd_skip_area_expect_response(13, old_current_area, Clusters.ServiceArea.SkipAreaStatus.kSuccess) + + test_step = "(Manual operation) wait for the device to skip the current area, and start operating at\ + the next one it should process, or stop operating" + self.print_step("14", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + if self.check_pics("SEAR.S.A0005"): + new_progress_list = await self.read_progress(15) + asserts.assert_true(len(new_progress_list) > 0, f"len of Progress({len(new_progress_list)}) should not be zero)") + + new_current_area = NullValue + if self.check_pics("SEAR.S.A0003"): + new_current_area = await self.read_current_area(16) + for p in new_progress_list: + if p.areaID == old_current_area: + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + "Progress for areaID({old_current_area}) should be Skipped") + break + test_step = "Indicate whether the device has stopped operating (y/n)" + ret = self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + if ret != "y": + for p in new_progress_list: + if p.areaID == new_current_area: + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kOperating, + "Progress for areaID({new_current_area}) should be Operating") + break + else: + was_only_skipped_or_completed = True + for p in old_progress_list: + if p.areaID != old_current_area: + if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + Clusters.ServiceArea.OperationalStatusEnum.kCompleted): + was_only_skipped_or_completed = False + break + if was_only_skipped_or_completed: + for p in new_progress_list: + if p.areaID == old_current_area: + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + "Progress for areaID({old_current_area}) should be Skipped") + break + self.print_step("17", "") + return + + if self.check_pics("SEAR.S.M.VALID_STATE_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): + test_step = "Manually intervene to put the device in a state that allows it to execute the SkipArea command" + self.print_step("18", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + self.print_step("19", "") + if len(old_progress_list) == 0: + return + + area_to_skip = NullValue + self.print_step("20", "") + for p in old_progress_list: + if p.status in (Clusters.ServiceArea.OperationalStatusEnum.kPending, + Clusters.ServiceArea.OperationalStatusEnum.kOperating): + area_to_skip = p.areaID + break + + if area_to_skip is NullValue: + return + + await self.send_cmd_skip_area_expect_response(21, area_to_skip, Clusters.ServiceArea.SkipAreaStatus.kSuccess) + + test_step = "(Manual operation) wait for the device to update Progress or to stop operating" + self.print_step("22", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + if self.check_pics("SEAR.S.A0005"): + new_progress_list = await self.read_progress(23) + asserts.assert_true(len(new_progress_list) > 0, f"len of Progress({len(new_progress_list)}) should not be zero)") + + for p in new_progress_list: + if p.areaID == area_to_skip: + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + "Progress for areaID({new_current_area}) should be Skipped") + break + + test_step = "Indicate whether the device has stopped operating (y/n)" + ret = self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + if ret != "y": + was_only_skipped_or_completed = True + for p in old_progress_list: + if p.areaID != area_to_skip: + if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + Clusters.ServiceArea.OperationalStatusEnum.kCompleted): + was_only_skipped_or_completed = False + break + if was_only_skipped_or_completed: + for p in new_progress_list: + if p.areaID == old_current_area: + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + "Progress for areaID({old_current_area}) should be Skipped") + break + + +if __name__ == "__main__": + default_matter_test_main() From 02ea3b80ce89935ae4d99bdcea94acb837f75c7e Mon Sep 17 00:00:00 2001 From: Petru Lauric <81822411+plauric@users.noreply.github.com> Date: Mon, 29 Jul 2024 13:26:54 -0400 Subject: [PATCH 06/15] Update src/python_testing/TC_SEAR_1_2.py Co-authored-by: William --- src/python_testing/TC_SEAR_1_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_SEAR_1_2.py b/src/python_testing/TC_SEAR_1_2.py index 993276533cd2d2..015252adb1f4f5 100644 --- a/src/python_testing/TC_SEAR_1_2.py +++ b/src/python_testing/TC_SEAR_1_2.py @@ -112,7 +112,7 @@ async def read_and_validate_supported_areas(self, step): if a.locationInfo is NullValue and a.landmarkTag is NullValue: asserts.assert_true(f"SupportedAreas entry with AreaID({a.areaID}) should not have null LocationInfo and null LandmarkTag") if a.landmarkTag is not NullValue: - asserts.assert_true(a.landmarkTag in range(0, self.MAX_LANDMARK_ID), + asserts.assert_true(a.landmarkTag <= self.MAX_LANDMARK_ID, f"SupportedAreas entry with AreaID({a.areaID}) has invalid LandmarkTag({a.landmarkTag})") asserts.assert_true(a.positionTag is NullValue or a.positionTag in range(0, self.MAX_RELPOS_ID), f"SupportedAreas entry with AreaID({a.areaID}) has invalid PositionTag({a.positionTag})") From db21e0414d53302c02ab47594334a1659a915fde Mon Sep 17 00:00:00 2001 From: Petru Lauric <81822411+plauric@users.noreply.github.com> Date: Mon, 29 Jul 2024 13:27:37 -0400 Subject: [PATCH 07/15] Update src/python_testing/TC_SEAR_1_2.py Co-authored-by: William --- src/python_testing/TC_SEAR_1_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_SEAR_1_2.py b/src/python_testing/TC_SEAR_1_2.py index 015252adb1f4f5..8c242322f0e1d1 100644 --- a/src/python_testing/TC_SEAR_1_2.py +++ b/src/python_testing/TC_SEAR_1_2.py @@ -177,7 +177,7 @@ async def read_and_validate_progress(self, step): endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.Progress) logging.info(f"Progress {progress}") - asserts.assert_true(len(self.selected_areas) <= len(self.areaid_list), + asserts.assert_true(len(progress) <= len(self.areaid_list), f"Progress(len {len(progress)}) should have at most {len(self.areaid_list)} entries") progareaid_list = [] From 9113ade83a68285b3d65269ea7164ba9f4897896 Mon Sep 17 00:00:00 2001 From: Petru Lauric Date: Mon, 29 Jul 2024 14:06:41 -0400 Subject: [PATCH 08/15] address code review comments --- src/python_testing/TC_SEAR_1_2.py | 129 +++++++++++++++--------------- src/python_testing/TC_SEAR_1_3.py | 22 ++--- src/python_testing/TC_SEAR_1_5.py | 24 +++--- src/python_testing/TC_SEAR_1_6.py | 8 +- 4 files changed, 90 insertions(+), 93 deletions(-) diff --git a/src/python_testing/TC_SEAR_1_2.py b/src/python_testing/TC_SEAR_1_2.py index 8c242322f0e1d1..d45822244af35f 100644 --- a/src/python_testing/TC_SEAR_1_2.py +++ b/src/python_testing/TC_SEAR_1_2.py @@ -88,34 +88,33 @@ async def read_and_validate_supported_areas(self, step): areaid_list = [] areadesc_s = set() for a in supported_areas: - if a.areaID in areaid_list: - asserts.fail("SupportedAreas must have unique AreaID values!") + asserts.assert_true(a.areaID not in areaid_list, "SupportedAreas must have unique AreaID values!") + + areaid_list.append(a.areaID) + + if len(self.mapid_list) > 0: + asserts.assert_is_not(a.mapID, NullValue, + f"SupportedAreas entry with AreaID({a.areaID}) should not have null MapID") + asserts.assert_is(a.mapID in self.mapid_list, + f"SupportedAreas entry with AreaID({a.areaID}) has unknown MapID({a.mapID})") + k = f"mapID:{a.mapID} areaDesc:{a.areaDesc}" + asserts.assert_true(k not in areadesc_s, f"SupportedAreas must have unique MapID({a.mapID}) + AreaDesc({a.areaDesc}) values!") + areadesc_s.add(k) else: - areaid_list.append(a.areaID) - - if len(self.mapid_list) > 0: - asserts.assert_is_not(a.mapID, NullValue, - f"SupportedAreas entry with AreaID({a.areaID}) should not have null MapID") - asserts.assert_is(a.mapID in self.mapid_list, - f"SupportedAreas entry with AreaID({a.areaID}) has unknown MapID({a.mapID})") - k = f"mapID:{a.mapID} areaDesc:{a.areaDesc}" - asserts.true(k not in areadesc_s, f"SupportedAreas must have unique MapID({a.mapID}) + AreaDesc({a.areaDesc}) values!") - areadesc_s.add(k) - else: - #empty SupportedMaps - asserts.assert_is(a.mapID, NullValue, - f"SupportedAreas entry with AreaID({a.areaID}) should have null MapID") - k = f"areaDesc:{a.areaDesc}" - asserts.true(k not in areadesc_s, f"SupportedAreas must have unique AreaDesc({a.areaDesc}) values!") - areadesc_s.add(k) - - if a.locationInfo is NullValue and a.landmarkTag is NullValue: - asserts.assert_true(f"SupportedAreas entry with AreaID({a.areaID}) should not have null LocationInfo and null LandmarkTag") - if a.landmarkTag is not NullValue: - asserts.assert_true(a.landmarkTag <= self.MAX_LANDMARK_ID, - f"SupportedAreas entry with AreaID({a.areaID}) has invalid LandmarkTag({a.landmarkTag})") - asserts.assert_true(a.positionTag is NullValue or a.positionTag in range(0, self.MAX_RELPOS_ID), - f"SupportedAreas entry with AreaID({a.areaID}) has invalid PositionTag({a.positionTag})") + #empty SupportedMaps + asserts.assert_is(a.mapID, NullValue, + f"SupportedAreas entry with AreaID({a.areaID}) should have null MapID") + k = f"areaDesc:{a.areaDesc}" + asserts.assert_true(k not in areadesc_s, f"SupportedAreas must have unique AreaDesc({a.areaDesc}) values!") + areadesc_s.add(k) + + if a.locationInfo is NullValue and a.landmarkTag is NullValue: + asserts.assert_true(f"SupportedAreas entry with AreaID({a.areaID}) should not have null LocationInfo and null LandmarkTag") + if a.landmarkTag is not NullValue: + asserts.assert_true(a.landmarkTag <= self.MAX_LANDMARK_ID, + f"SupportedAreas entry with AreaID({a.areaID}) has invalid LandmarkTag({a.landmarkTag})") + asserts.assert_true(a.positionTag is NullValue or a.positionTag in range(0, self.MAX_RELPOS_ID), + f"SupportedAreas entry with AreaID({a.areaID}) has invalid PositionTag({a.positionTag})") #save so other methods can use this if neeeded self.areaid_list = areaid_list @@ -130,14 +129,12 @@ async def read_and_validate_selected_areas(self, step): asserts.assert_true(len(selected_areas) <= len(self.areaid_list), f"SelectedAreas(len {len(selected_areas)}) should have at most {len(self.areaid_list)} entries") - selareaid_list = [] + asserts.assert_true(len(set(selected_areas)) == len(selected_areas), "SelectedAreas must have unique AreaID values!") + selareaid_list = [] for a in selected_areas: - if a.areaID in selareaid_list: - asserts.fail("SelectedAreas must have unique AreaID values!") - else: - selareaid_list.append(a.areaID) - asserts.assert_true(a.areaID in self.areaid_list, - f"SelectedAreas entry {a.areaID} has invalid value") + selareaid_list.append(a) + asserts.assert_true(a in self.areaid_list, + f"SelectedAreas entry {a} has invalid value") #save so other methods can use this if neeeded self.selareaid_list = selareaid_list @@ -227,20 +224,20 @@ async def test_TC_SEAR_1_2(self): self.write_to_app_pipe('{"Name": "Reset"}') if self.check_pics("SEAR.S.F02"): - await self.read_and_validate_supported_maps(2) + await self.read_and_validate_supported_maps(step=2) - await self.read_and_validate_supported_areas(3) + await self.read_and_validate_supported_areas(step=3) - await self.read_and_validate_selected_areas(4) + await self.read_and_validate_selected_areas(step=4) if self.check_pics("SEAR.S.A0003"): - await self.read_and_validate_current_area(5) + await self.read_and_validate_current_area(step=5) if self.check_pics("SEAR.S.A0004"): - await self.read_and_validate_estimated_end_time(6) + await self.read_and_validate_estimated_end_time(step=6) if self.check_pics("SEAR.S.A0005"): - await self.read_and_validate_progress(7) + await self.read_and_validate_progress(step=7) if self.check_pics("SEAR.S.F02") and self.check_pics("SEAR.S.M.REMOVE_MAP"): test_step = "Manually ensure the SupportedMaps attribute is not empty and that the device is not operating" @@ -248,7 +245,7 @@ async def test_TC_SEAR_1_2(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.read_and_validate_supported_maps(9) + await self.read_and_validate_supported_maps(step=9) old_supported_maps = self.mapid_list test_step = "Manually intervene to remove one or more entries in the SupportedMaps list" @@ -256,24 +253,24 @@ async def test_TC_SEAR_1_2(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.read_and_validate_supported_maps(11) + await self.read_and_validate_supported_maps(step=11) new_supported_maps = self.mapid_list asserts.assert_true(len(old_supported_maps) > len(new_supported_maps), "Failed to remove map(s)") #NOTE the following operations are all part of step 11 - read all these attributes and check the data consistency # after removing map(s) - await self.read_and_validate_supported_areas(11) + await self.read_and_validate_supported_areas(step=11) - await self.read_and_validate_selected_areas(11) + await self.read_and_validate_selected_areas(step=11) if self.check_pics("SEAR.S.A0003"): - await self.read_and_validate_current_area(11) + await self.read_and_validate_current_area(step=11) if self.check_pics("SEAR.S.A0004"): - await self.read_and_validate_estimated_end_time(11) + await self.read_and_validate_estimated_end_time(step=11) if self.check_pics("SEAR.S.A0005"): - await self.read_and_validate_progress(11) + await self.read_and_validate_progress(step=11) if self.check_pics("SEAR.S.F02") and self.check_pics("SEAR.S.M.ADD_MAP"): test_step = "Manually ensure the SupportedMaps attribute has less than 255 entries and that the device is not operating" @@ -281,7 +278,7 @@ async def test_TC_SEAR_1_2(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.read_and_validate_supported_maps(13) + await self.read_and_validate_supported_maps(step=13) old_supported_maps = self.mapid_list test_step = "Manually intervene to add one or more entries to the SupportedMaps list" @@ -289,24 +286,24 @@ async def test_TC_SEAR_1_2(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.read_and_validate_supported_maps(15) + await self.read_and_validate_supported_maps(step=15) new_supported_maps = self.mapid_list asserts.assert_true(len(old_supported_maps) < len(new_supported_maps), "Failed to add map(s)") #NOTE the following operations are all part of step 15 - read all these attributes and check the data consistency # after adding map(s) - await self.read_and_validate_supported_areas(15) + await self.read_and_validate_supported_areas(step=15) - await self.read_and_validate_selected_areas(15) + await self.read_and_validate_selected_areas(step=15) if self.check_pics("SEAR.S.A0003"): - await self.read_and_validate_current_area(15) + await self.read_and_validate_current_area(step=15) if self.check_pics("SEAR.S.A0004"): - await self.read_and_validate_estimated_end_time(15) + await self.read_and_validate_estimated_end_time(step=15) if self.check_pics("SEAR.S.A0005"): - await self.read_and_validate_progress(15) + await self.read_and_validate_progress(step=15) if self.check_pics("SEAR.S.M.REMOVE_AREA"): test_step = "Manually ensure the SupportedAreas attribute is not empty and that the device is not operating" @@ -314,7 +311,7 @@ async def test_TC_SEAR_1_2(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.read_and_validate_supported_areas(17) + await self.read_and_validate_supported_areas(step=17) old_supported_areas = self.areaid_list test_step = "Manually intervene to remove one or more entries from the SupportedAreas list" @@ -322,23 +319,23 @@ async def test_TC_SEAR_1_2(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.read_and_validate_supported_areas(19) + await self.read_and_validate_supported_areas(step=19) new_supported_areas = self.areaid_list asserts.assert_true(len(old_supported_areas) > len(new_supported_areas), "Failed to remove area(s)") #NOTE the following operations are all part of step 19 - read all these attributes and check the data consistency # after removing areas(s) - await self.read_and_validate_selected_areas(19) + await self.read_and_validate_selected_areas(step=19) if self.check_pics("SEAR.S.A0003"): - await self.read_and_validate_current_area(19) + await self.read_and_validate_current_area(step=19) if self.check_pics("SEAR.S.A0004"): - await self.read_and_validate_estimated_end_time(19) + await self.read_and_validate_estimated_end_time(step=19) if self.check_pics("SEAR.S.A0005"): - await self.read_and_validate_progress(19) + await self.read_and_validate_progress(step=19) if self.check_pics("SEAR.S.M.ADD_AREA"): test_step = "Manually ensure the SupportedAreas attribute has less than 255 entries and that the device is not operating" @@ -346,7 +343,7 @@ async def test_TC_SEAR_1_2(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.read_and_validate_supported_areas(21) + await self.read_and_validate_supported_areas(step=21) old_supported_areas = self.areaid_list test_step = "Manually intervene to add one or more entries to the SupportedAreas list" @@ -354,23 +351,23 @@ async def test_TC_SEAR_1_2(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.read_and_validate_supported_areas(23) + await self.read_and_validate_supported_areas(step=23) new_supported_areas = self.areaid_list asserts.assert_true(len(old_supported_areas) < len(new_supported_areas), "Failed to add area(s)") #NOTE the following operations are all part of step 23 - read all these attributes and check the data consistency # after removing areas(s) - await self.read_and_validate_selected_areas(23) + await self.read_and_validate_selected_areas(step=23) if self.check_pics("SEAR.S.A0003"): - await self.read_and_validate_current_area(23) + await self.read_and_validate_current_area(step=23) if self.check_pics("SEAR.S.A0004"): - await self.read_and_validate_estimated_end_time(23) + await self.read_and_validate_estimated_end_time(step=23) if self.check_pics("SEAR.S.A0005"): - await self.read_and_validate_progress(23) + await self.read_and_validate_progress(step=23) if __name__ == "__main__": diff --git a/src/python_testing/TC_SEAR_1_3.py b/src/python_testing/TC_SEAR_1_3.py index db2204970e1da4..e7ae4e774bf37b 100644 --- a/src/python_testing/TC_SEAR_1_3.py +++ b/src/python_testing/TC_SEAR_1_3.py @@ -107,7 +107,7 @@ async def test_TC_SEAR_1_3(self): if self.is_ci: self.write_to_app_pipe('{"Name": "Reset"}') - supported_area_ids = await self.read_supported_areas(2) + supported_area_ids = await self.read_supported_areas(step=2) asserts.assert_true(len(self.supported_areas) > 0, "SupportedAreas is empty") valid_area_id = supported_area_ids[0] invalid_area_id = 1 + max(supported_area_ids) @@ -115,14 +115,14 @@ async def test_TC_SEAR_1_3(self): duplicated_areas = [valid_area_id, valid_area_id] #FIXME need to check if this is the correct name of this status code - await self.send_cmd_select_areas_expect_response(3, duplicated_areas, Clusters.ServiceArea.SelectAreasStatus.kDuplicatedAreas) + await self.send_cmd_select_areas_expect_response(step=3, duplicated_areas, Clusters.ServiceArea.SelectAreasStatus.kDuplicatedAreas) - await self.send_cmd_select_areas_expect_response(4, [], Clusters.ServiceArea.SelectAreasStatus.kSuccess) + await self.send_cmd_select_areas_expect_response(step=4, [], Clusters.ServiceArea.SelectAreasStatus.kSuccess) - selected_areas = await self.read_selected_areas(5) + selected_areas = await self.read_selected_areas(step=5) asserts.assert_true(len(selected_areas) == 0, "SelectedAreas should be empty") - await self.send_cmd_select_areas_expect_response(6, [invalid_area_id], Clusters.ServiceArea.SelectAreasStatus.kUnsupportedArea) + await self.send_cmd_select_areas_expect_response(step=6, [invalid_area_id], Clusters.ServiceArea.SelectAreasStatus.kUnsupportedArea) if self.check_pics("SEAR.S.M.INVALID_STATE_FOR_SELECT_AREAS") and self.check_pics("SEAR.S.M.HAS_MANUAL_SELAREA_STATE_CONTROL"): test_step = "Manually intervene to put the device in a state that prevents it from executing the SelectAreas command" @@ -130,7 +130,7 @@ async def test_TC_SEAR_1_3(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_select_areas_expect_response(8, [valid_area_id], Clusters.ServiceArea.SelectAreasStatus.kInvalidInMode) + await self.send_cmd_select_areas_expect_response(step=8, [valid_area_id], Clusters.ServiceArea.SelectAreasStatus.kInvalidInMode) if self.check_pics("SEAR.S.M.VALID_STATE_FOR_SELECT_AREAS") and self.check_pics("SEAR.S.M.HAS_MANUAL_SELAREA_STATE_CONTROL"): test_step = f"Manually intervene to put the device in a state that allows it to execute the SelectAreas({supported_area_ids}) command" @@ -138,12 +138,12 @@ async def test_TC_SEAR_1_3(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_select_areas_expect_response(10, supported_area_ids, Clusters.ServiceArea.SelectAreasStatus.kSuccess) + await self.send_cmd_select_areas_expect_response(step=10, supported_area_ids, Clusters.ServiceArea.SelectAreasStatus.kSuccess) - selected_areas = await self.read_selected_areas(11) + selected_areas = await self.read_selected_areas(step=11) asserts.assert_true(len(selected_areas) == len(supported_area_ids), f"SelectedAreas({selected_areas}) should match SupportedAreas({supported_area_ids})") - await self.send_cmd_select_areas_expect_response(12, supported_area_ids, Clusters.ServiceArea.SelectAreasStatus.kSuccess) + await self.send_cmd_select_areas_expect_response(step=12, supported_area_ids, Clusters.ServiceArea.SelectAreasStatus.kSuccess) if self.check_pics("SEAR.S.M.VALID_STATE_FOR_SELECT_AREAS") and self.check_pics("SEAR.S.M.HAS_MANUAL_SELAREA_STATE_CONTROL") and self.check_pics("SEAR.S.M.SELECT_AREAS_WHILE_NON_IDLE"): test_step = f"Manually intervene to put the device in a state that allows it to execute the SelectAreas({valid_area_id}) command, and put the device in a non-idle state" @@ -152,9 +152,9 @@ async def test_TC_SEAR_1_3(self): self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") if self.check_pics("SEAR.S.F00"): - await self.send_cmd_select_areas_expect_response(14, [valid_area_id], Clusters.ServiceArea.SelectAreasStatus.kSuccess) + await self.send_cmd_select_areas_expect_response(step=14, [valid_area_id], Clusters.ServiceArea.SelectAreasStatus.kSuccess) else: - await self.send_cmd_select_areas_expect_response(14, [valid_area_id], Clusters.ServiceArea.SelectAreasStatus.kInvalidInMode) + await self.send_cmd_select_areas_expect_response(step=14, [valid_area_id], Clusters.ServiceArea.SelectAreasStatus.kInvalidInMode) diff --git a/src/python_testing/TC_SEAR_1_5.py b/src/python_testing/TC_SEAR_1_5.py index 0315532d97b204..647ecc106846ad 100644 --- a/src/python_testing/TC_SEAR_1_5.py +++ b/src/python_testing/TC_SEAR_1_5.py @@ -123,7 +123,7 @@ async def test_TC_SEAR_1_5(self): if self.is_ci: self.write_to_app_pipe('{"Name": "Reset"}') - supported_area_ids = await self.read_supported_areas(2) + supported_area_ids = await self.read_supported_areas(step=2) asserts.assert_true(len(supported_area_ids) > 0, "SupportedAreas is empty") valid_area_id = supported_area_ids[0] invalid_area_id = 1 + max(supported_area_ids) @@ -135,7 +135,7 @@ async def test_TC_SEAR_1_5(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_skip_area_expect_response(4, valid_area_id, Clusters.ServiceArea.SkipAreaStatus.kInvalidInMode) + await self.send_cmd_skip_area_expect_response(step=4, valid_area_id, Clusters.ServiceArea.SkipAreaStatus.kInvalidInMode) if self.check_pics("SEAR.S.M.NO_SELAREA_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): test_step = "Manually intervene to put the device in a state where the state would allow it to execute the SkipArea command, \ @@ -144,7 +144,7 @@ async def test_TC_SEAR_1_5(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_skip_area_expect_response(6, valid_area_id, Clusters.ServiceArea.SkipAreaStatus.kInvalidAreaList) + await self.send_cmd_skip_area_expect_response(step=6, valid_area_id, Clusters.ServiceArea.SkipAreaStatus.kInvalidAreaList) if self.check_pics("SEAR.S.M.VALID_STATE_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): test_step = "Manually intervene to put the device in a state that allows it to execute the SkipArea command" @@ -152,22 +152,22 @@ async def test_TC_SEAR_1_5(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_skip_area_expect_response(8, invalid_area_id, Clusters.ServiceArea.SkipAreaStatus.kInvalidSkippedArea) + await self.send_cmd_skip_area_expect_response(step=8, invalid_area_id, Clusters.ServiceArea.SkipAreaStatus.kInvalidSkippedArea) if self.check_pics("SEAR.S.A0005"): - old_progress_list = await self.read_progress(9) + old_progress_list = await self.read_progress(step=9) asserts.assert_true(len(old_progress_list) > 0, f"len of Progress({len(old_progress_list)}) should not be zero)") - selected_areas = await self.read_selected_areas(10) + selected_areas = await self.read_selected_areas(step=10) asserts.assert_true(len(selected_areas) > 0, "SelectedAreas is empty") old_current_area = NullValue if self.check_pics("SEAR.S.A0003"): - old_current_area = await self.read_current_area(11) + old_current_area = await self.read_current_area(step=11) self.print_step("12", "") if old_current_area is not NullValue: - await self.send_cmd_skip_area_expect_response(13, old_current_area, Clusters.ServiceArea.SkipAreaStatus.kSuccess) + await self.send_cmd_skip_area_expect_response(step=13, old_current_area, Clusters.ServiceArea.SkipAreaStatus.kSuccess) test_step = "(Manual operation) wait for the device to skip the current area, and start operating at\ the next one it should process, or stop operating" @@ -176,12 +176,12 @@ async def test_TC_SEAR_1_5(self): self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") if self.check_pics("SEAR.S.A0005"): - new_progress_list = await self.read_progress(15) + new_progress_list = await self.read_progress(step=15) asserts.assert_true(len(new_progress_list) > 0, f"len of Progress({len(new_progress_list)}) should not be zero)") new_current_area = NullValue if self.check_pics("SEAR.S.A0003"): - new_current_area = await self.read_current_area(16) + new_current_area = await self.read_current_area(step=16) for p in new_progress_list: if p.areaID == old_current_area: asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, @@ -234,7 +234,7 @@ async def test_TC_SEAR_1_5(self): if area_to_skip is NullValue: return - await self.send_cmd_skip_area_expect_response(21, area_to_skip, Clusters.ServiceArea.SkipAreaStatus.kSuccess) + await self.send_cmd_skip_area_expect_response(step=21, area_to_skip, Clusters.ServiceArea.SkipAreaStatus.kSuccess) test_step = "(Manual operation) wait for the device to update Progress or to stop operating" self.print_step("22", test_step) @@ -242,7 +242,7 @@ async def test_TC_SEAR_1_5(self): self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") if self.check_pics("SEAR.S.A0005"): - new_progress_list = await self.read_progress(23) + new_progress_list = await self.read_progress(step=23) asserts.assert_true(len(new_progress_list) > 0, f"len of Progress({len(new_progress_list)}) should not be zero)") for p in new_progress_list: diff --git a/src/python_testing/TC_SEAR_1_6.py b/src/python_testing/TC_SEAR_1_6.py index 6398215cf8b122..4324e4415ea211 100644 --- a/src/python_testing/TC_SEAR_1_6.py +++ b/src/python_testing/TC_SEAR_1_6.py @@ -114,10 +114,10 @@ async def test_TC_SEAR_1_6(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - supported_area_ids = await self.read_supported_areas(3) + supported_area_ids = await self.read_supported_areas(step=3) asserts.assert_true(len(supported_area_ids) > 0, "SupportedAreas is empty") - selected_areas = await self.read_selected_areas(4) + selected_areas = await self.read_selected_areas(step=4) asserts.assert_true(len(selected_areas) > 0, "SelectedAreas is empty") test_step = "Manually intervene to put the device in the operating state" @@ -125,7 +125,7 @@ async def test_TC_SEAR_1_6(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - progress_list_operating = await self.read_progress(6) + progress_list_operating = await self.read_progress(step=6) asserts.assert_true(len(selected_areas) == len(progress_list_operating), f"len of SelectedAreas({len(selected_areas)}) should be equal to len of Progress({len(progress_list_operating)})") for p in progress_list_operating: @@ -142,7 +142,7 @@ async def test_TC_SEAR_1_6(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - progress_list_idle = await self.read_progress(8) + progress_list_idle = await self.read_progress(step=8) asserts.assert_true(len(selected_areas) == len(progress_list_idle), f"len of SelectedAreas({len(selected_areas)}) should be equal to len of Progress({len(progress_list_idle)})") for p in progress_list_idle: From 6ae583dce4b5e149854e3f383874b24609e3deb1 Mon Sep 17 00:00:00 2001 From: Petru Lauric Date: Mon, 29 Jul 2024 14:27:44 -0400 Subject: [PATCH 09/15] fix issue introduced by the previous commit --- src/python_testing/TC_SEAR_1_3.py | 16 ++++++++-------- src/python_testing/TC_SEAR_1_5.py | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/python_testing/TC_SEAR_1_3.py b/src/python_testing/TC_SEAR_1_3.py index e7ae4e774bf37b..fcd57fd139f580 100644 --- a/src/python_testing/TC_SEAR_1_3.py +++ b/src/python_testing/TC_SEAR_1_3.py @@ -115,14 +115,14 @@ async def test_TC_SEAR_1_3(self): duplicated_areas = [valid_area_id, valid_area_id] #FIXME need to check if this is the correct name of this status code - await self.send_cmd_select_areas_expect_response(step=3, duplicated_areas, Clusters.ServiceArea.SelectAreasStatus.kDuplicatedAreas) + await self.send_cmd_select_areas_expect_response(step=3, new_areas=duplicated_areas, expected_response=Clusters.ServiceArea.SelectAreasStatus.kDuplicatedAreas) - await self.send_cmd_select_areas_expect_response(step=4, [], Clusters.ServiceArea.SelectAreasStatus.kSuccess) + await self.send_cmd_select_areas_expect_response(step=4, new_areas=[], expected_response=Clusters.ServiceArea.SelectAreasStatus.kSuccess) selected_areas = await self.read_selected_areas(step=5) asserts.assert_true(len(selected_areas) == 0, "SelectedAreas should be empty") - await self.send_cmd_select_areas_expect_response(step=6, [invalid_area_id], Clusters.ServiceArea.SelectAreasStatus.kUnsupportedArea) + await self.send_cmd_select_areas_expect_response(step=6, new_areas=[invalid_area_id], expected_response=Clusters.ServiceArea.SelectAreasStatus.kUnsupportedArea) if self.check_pics("SEAR.S.M.INVALID_STATE_FOR_SELECT_AREAS") and self.check_pics("SEAR.S.M.HAS_MANUAL_SELAREA_STATE_CONTROL"): test_step = "Manually intervene to put the device in a state that prevents it from executing the SelectAreas command" @@ -130,7 +130,7 @@ async def test_TC_SEAR_1_3(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_select_areas_expect_response(step=8, [valid_area_id], Clusters.ServiceArea.SelectAreasStatus.kInvalidInMode) + await self.send_cmd_select_areas_expect_response(step=8, new_areas=[valid_area_id], expected_response=Clusters.ServiceArea.SelectAreasStatus.kInvalidInMode) if self.check_pics("SEAR.S.M.VALID_STATE_FOR_SELECT_AREAS") and self.check_pics("SEAR.S.M.HAS_MANUAL_SELAREA_STATE_CONTROL"): test_step = f"Manually intervene to put the device in a state that allows it to execute the SelectAreas({supported_area_ids}) command" @@ -138,12 +138,12 @@ async def test_TC_SEAR_1_3(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_select_areas_expect_response(step=10, supported_area_ids, Clusters.ServiceArea.SelectAreasStatus.kSuccess) + await self.send_cmd_select_areas_expect_response(step=10, new_areas=supported_area_ids, expected_response=Clusters.ServiceArea.SelectAreasStatus.kSuccess) selected_areas = await self.read_selected_areas(step=11) asserts.assert_true(len(selected_areas) == len(supported_area_ids), f"SelectedAreas({selected_areas}) should match SupportedAreas({supported_area_ids})") - await self.send_cmd_select_areas_expect_response(step=12, supported_area_ids, Clusters.ServiceArea.SelectAreasStatus.kSuccess) + await self.send_cmd_select_areas_expect_response(step=12, new_areas=supported_area_ids, expected_response=Clusters.ServiceArea.SelectAreasStatus.kSuccess) if self.check_pics("SEAR.S.M.VALID_STATE_FOR_SELECT_AREAS") and self.check_pics("SEAR.S.M.HAS_MANUAL_SELAREA_STATE_CONTROL") and self.check_pics("SEAR.S.M.SELECT_AREAS_WHILE_NON_IDLE"): test_step = f"Manually intervene to put the device in a state that allows it to execute the SelectAreas({valid_area_id}) command, and put the device in a non-idle state" @@ -152,9 +152,9 @@ async def test_TC_SEAR_1_3(self): self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") if self.check_pics("SEAR.S.F00"): - await self.send_cmd_select_areas_expect_response(step=14, [valid_area_id], Clusters.ServiceArea.SelectAreasStatus.kSuccess) + await self.send_cmd_select_areas_expect_response(step=14, new_areas=[valid_area_id], expected_response=Clusters.ServiceArea.SelectAreasStatus.kSuccess) else: - await self.send_cmd_select_areas_expect_response(step=14, [valid_area_id], Clusters.ServiceArea.SelectAreasStatus.kInvalidInMode) + await self.send_cmd_select_areas_expect_response(step=14, new_areas=[valid_area_id], expected_response=Clusters.ServiceArea.SelectAreasStatus.kInvalidInMode) diff --git a/src/python_testing/TC_SEAR_1_5.py b/src/python_testing/TC_SEAR_1_5.py index 647ecc106846ad..8ee508de5c515a 100644 --- a/src/python_testing/TC_SEAR_1_5.py +++ b/src/python_testing/TC_SEAR_1_5.py @@ -135,7 +135,7 @@ async def test_TC_SEAR_1_5(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_skip_area_expect_response(step=4, valid_area_id, Clusters.ServiceArea.SkipAreaStatus.kInvalidInMode) + await self.send_cmd_skip_area_expect_response(step=4, skipped_area=valid_area_id, expected_response=Clusters.ServiceArea.SkipAreaStatus.kInvalidInMode) if self.check_pics("SEAR.S.M.NO_SELAREA_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): test_step = "Manually intervene to put the device in a state where the state would allow it to execute the SkipArea command, \ @@ -144,7 +144,7 @@ async def test_TC_SEAR_1_5(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_skip_area_expect_response(step=6, valid_area_id, Clusters.ServiceArea.SkipAreaStatus.kInvalidAreaList) + await self.send_cmd_skip_area_expect_response(step=6, skipped_area=valid_area_id, expected_response=Clusters.ServiceArea.SkipAreaStatus.kInvalidAreaList) if self.check_pics("SEAR.S.M.VALID_STATE_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): test_step = "Manually intervene to put the device in a state that allows it to execute the SkipArea command" @@ -152,7 +152,7 @@ async def test_TC_SEAR_1_5(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_skip_area_expect_response(step=8, invalid_area_id, Clusters.ServiceArea.SkipAreaStatus.kInvalidSkippedArea) + await self.send_cmd_skip_area_expect_response(step=8, skipped_area=invalid_area_id, expected_response=Clusters.ServiceArea.SkipAreaStatus.kInvalidSkippedArea) if self.check_pics("SEAR.S.A0005"): old_progress_list = await self.read_progress(step=9) @@ -167,7 +167,7 @@ async def test_TC_SEAR_1_5(self): self.print_step("12", "") if old_current_area is not NullValue: - await self.send_cmd_skip_area_expect_response(step=13, old_current_area, Clusters.ServiceArea.SkipAreaStatus.kSuccess) + await self.send_cmd_skip_area_expect_response(step=13, skipped_area=old_current_area, expected_response=Clusters.ServiceArea.SkipAreaStatus.kSuccess) test_step = "(Manual operation) wait for the device to skip the current area, and start operating at\ the next one it should process, or stop operating" @@ -234,7 +234,7 @@ async def test_TC_SEAR_1_5(self): if area_to_skip is NullValue: return - await self.send_cmd_skip_area_expect_response(step=21, area_to_skip, Clusters.ServiceArea.SkipAreaStatus.kSuccess) + await self.send_cmd_skip_area_expect_response(step=21, skipped_area=area_to_skip, expected_response=Clusters.ServiceArea.SkipAreaStatus.kSuccess) test_step = "(Manual operation) wait for the device to update Progress or to stop operating" self.print_step("22", test_step) From 8d6af88bc05bb2ffcc86f65f935adb8924ac0310 Mon Sep 17 00:00:00 2001 From: Petru Lauric Date: Tue, 30 Jul 2024 17:37:51 -0400 Subject: [PATCH 10/15] address code review feedback --- src/python_testing/TC_SEAR_1_2.py | 7 +- src/python_testing/TC_SEAR_1_3.py | 11 +- src/python_testing/TC_SEAR_1_4.py | 4 +- src/python_testing/TC_SEAR_1_5.py | 199 +++++++++++++++--------------- src/python_testing/TC_SEAR_1_6.py | 14 +-- 5 files changed, 111 insertions(+), 124 deletions(-) diff --git a/src/python_testing/TC_SEAR_1_2.py b/src/python_testing/TC_SEAR_1_2.py index d45822244af35f..eb1cdaea4be335 100644 --- a/src/python_testing/TC_SEAR_1_2.py +++ b/src/python_testing/TC_SEAR_1_2.py @@ -130,13 +130,12 @@ async def read_and_validate_selected_areas(self, step): f"SelectedAreas(len {len(selected_areas)}) should have at most {len(self.areaid_list)} entries") asserts.assert_true(len(set(selected_areas)) == len(selected_areas), "SelectedAreas must have unique AreaID values!") - selareaid_list = [] - for a in selected_areas: - selareaid_list.append(a) + + for a in selected_areas: asserts.assert_true(a in self.areaid_list, f"SelectedAreas entry {a} has invalid value") #save so other methods can use this if neeeded - self.selareaid_list = selareaid_list + self.selareaid_list = selected_areas async def read_and_validate_current_area(self, step): self.print_step(step, "Read CurrentArea attribute") diff --git a/src/python_testing/TC_SEAR_1_3.py b/src/python_testing/TC_SEAR_1_3.py index fcd57fd139f580..94eb89f6dfaf20 100644 --- a/src/python_testing/TC_SEAR_1_3.py +++ b/src/python_testing/TC_SEAR_1_3.py @@ -53,10 +53,7 @@ async def read_supported_areas(self, step): endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SupportedAreas) logging.info("SupportedAreas: %s" % (supported_areas)) - areaid_list = [] - for a in supported_areas: - areaid_list.append(a.areaID) - return areaid_list + return [a.areaID for a in supported_areas] async def read_selected_areas(self, step): self.print_step(step, "Read SelectedAreas attribute") @@ -64,11 +61,7 @@ async def read_selected_areas(self, step): endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SelectedAreas) logging.info(f"SelectedAreas {selected_areas}") - selareaid_list = [] - for a in selected_areas: - selareaid_list.append(a.areaID) - return selareaid_list - + return [a.areaID for a in selected_areas] async def send_cmd_select_areas_expect_response(self, step, new_areas, expected_response): self.print_step(step, f"Send SelectAreas command with NewAreas({new_areas})") diff --git a/src/python_testing/TC_SEAR_1_4.py b/src/python_testing/TC_SEAR_1_4.py index 6c56d9ae9b6c8b..dffdda0db67734 100644 --- a/src/python_testing/TC_SEAR_1_4.py +++ b/src/python_testing/TC_SEAR_1_4.py @@ -70,7 +70,9 @@ async def test_TC_SEAR_1_4(self): endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.AttributeList) logging.info("AttributeList: %s" % (attribute_list)) - if not (Clusters.ServiceArea.Attributes.CurrentArea in attribute_list and Clusters.ServiceArea.Attributes.Progress in attribute_list): + if Clusters.ServiceArea.Attributes.CurrentArea not in attribute_list \ + and Clusters.ServiceArea.Attributes.Progress not in attribute_list: + cmd_list = await self.read_sear_attribute_expect_success( endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.AcceptedCommandList) logging.info("AcceptedCommandList: %s" % (cmd_list)) diff --git a/src/python_testing/TC_SEAR_1_5.py b/src/python_testing/TC_SEAR_1_5.py index 8ee508de5c515a..043465fcb735c4 100644 --- a/src/python_testing/TC_SEAR_1_5.py +++ b/src/python_testing/TC_SEAR_1_5.py @@ -53,10 +53,7 @@ async def read_supported_areas(self, step): endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SupportedAreas) logging.info("SupportedAreas: %s" % (supported_areas)) - areaid_list = [] - for a in supported_areas: - areaid_list.append(a.areaID) - return areaid_list + return [a.areaID for a in supported_areas] async def read_selected_areas(self, step): self.print_step(step, "Read SelectedAreas attribute") @@ -64,10 +61,7 @@ async def read_selected_areas(self, step): endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SelectedAreas) logging.info(f"SelectedAreas {selected_areas}") - selareaid_list = [] - for a in selected_areas: - selareaid_list.append(a.areaID) - return selareaid_list + return selected_areas async def read_progress(self, step): self.print_step(step, "Read Progress attribute") @@ -104,7 +98,7 @@ def write_to_app_pipe(self, command): sleep(0.001) def TC_SEAR_1_5(self) -> list[str]: - return ["SEAR.S", "SEAR.S.A0005", "SEAR.S.M.HAS_MANUAL_OPERATING_STATE_CONTROL"] + return ["SEAR.S", "SEAR.S.C02.Rsp"] @async_test_body async def test_TC_SEAR_1_5(self): @@ -135,7 +129,8 @@ async def test_TC_SEAR_1_5(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_skip_area_expect_response(step=4, skipped_area=valid_area_id, expected_response=Clusters.ServiceArea.SkipAreaStatus.kInvalidInMode) + await self.send_cmd_skip_area_expect_response(step=4, skipped_area=valid_area_id, + expected_response=Clusters.ServiceArea.SkipAreaStatus.kInvalidInMode) if self.check_pics("SEAR.S.M.NO_SELAREA_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): test_step = "Manually intervene to put the device in a state where the state would allow it to execute the SkipArea command, \ @@ -144,7 +139,8 @@ async def test_TC_SEAR_1_5(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_skip_area_expect_response(step=6, skipped_area=valid_area_id, expected_response=Clusters.ServiceArea.SkipAreaStatus.kInvalidAreaList) + await self.send_cmd_skip_area_expect_response(step=6, skipped_area=valid_area_id, + expected_response=Clusters.ServiceArea.SkipAreaStatus.kInvalidAreaList) if self.check_pics("SEAR.S.M.VALID_STATE_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): test_step = "Manually intervene to put the device in a state that allows it to execute the SkipArea command" @@ -152,77 +148,80 @@ async def test_TC_SEAR_1_5(self): if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_skip_area_expect_response(step=8, skipped_area=invalid_area_id, expected_response=Clusters.ServiceArea.SkipAreaStatus.kInvalidSkippedArea) + await self.send_cmd_skip_area_expect_response(step=8, skipped_area=invalid_area_id, + expected_response=Clusters.ServiceArea.SkipAreaStatus.kInvalidSkippedArea) - if self.check_pics("SEAR.S.A0005"): - old_progress_list = await self.read_progress(step=9) - asserts.assert_true(len(old_progress_list) > 0, f"len of Progress({len(old_progress_list)}) should not be zero)") + if not self.check_pics("SEAR.S.M.VALID_STATE_FOR_SKIP"): + return + + if self.check_pics("SEAR.S.A0005"): + old_progress_list = await self.read_progress(step=9) + asserts.assert_true(len(old_progress_list) > 0, f"len of Progress({len(old_progress_list)}) should not be zero)") - selected_areas = await self.read_selected_areas(step=10) - asserts.assert_true(len(selected_areas) > 0, "SelectedAreas is empty") + selected_areas = await self.read_selected_areas(step=10) + asserts.assert_true(len(selected_areas) > 0, "SelectedAreas is empty") - old_current_area = NullValue - if self.check_pics("SEAR.S.A0003"): - old_current_area = await self.read_current_area(step=11) + old_current_area = NullValue + if self.check_pics("SEAR.S.A0003"): + old_current_area = await self.read_current_area(step=11) self.print_step("12", "") if old_current_area is not NullValue: - await self.send_cmd_skip_area_expect_response(step=13, skipped_area=old_current_area, expected_response=Clusters.ServiceArea.SkipAreaStatus.kSuccess) - - test_step = "(Manual operation) wait for the device to skip the current area, and start operating at\ - the next one it should process, or stop operating" - self.print_step("14", test_step) - if not self.is_ci: - self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - - if self.check_pics("SEAR.S.A0005"): - new_progress_list = await self.read_progress(step=15) - asserts.assert_true(len(new_progress_list) > 0, f"len of Progress({len(new_progress_list)}) should not be zero)") - - new_current_area = NullValue - if self.check_pics("SEAR.S.A0003"): - new_current_area = await self.read_current_area(step=16) - for p in new_progress_list: - if p.areaID == old_current_area: - asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, - "Progress for areaID({old_current_area}) should be Skipped") - break - test_step = "Indicate whether the device has stopped operating (y/n)" - ret = self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - - if ret != "y": - for p in new_progress_list: - if p.areaID == new_current_area: - asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kOperating, - "Progress for areaID({new_current_area}) should be Operating") - break - else: - was_only_skipped_or_completed = True - for p in old_progress_list: - if p.areaID != old_current_area: - if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped, - Clusters.ServiceArea.OperationalStatusEnum.kCompleted): - was_only_skipped_or_completed = False - break - if was_only_skipped_or_completed: - for p in new_progress_list: - if p.areaID == old_current_area: - asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, - "Progress for areaID({old_current_area}) should be Skipped") - break + await self.send_cmd_skip_area_expect_response(step=13, skipped_area=old_current_area, + expected_response=Clusters.ServiceArea.SkipAreaStatus.kSuccess) + if self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): + test_step = "(Manual operation) wait for the device to skip the current area, and start operating at\ + the next one it should process, or stop operating" + self.print_step("14", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + if self.check_pics("SEAR.S.A0005"): + new_progress_list = await self.read_progress(step=15) + asserts.assert_true(len(new_progress_list) > 0, f"len of Progress({len(new_progress_list)}) should not be zero)") + + new_current_area = NullValue + if self.check_pics("SEAR.S.A0003"): + new_current_area = await self.read_current_area(step=16) + for p in new_progress_list: + if p.areaID == old_current_area: + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + "Progress for areaID({old_current_area}) should be Skipped") + break + test_step = "Indicate whether the device has stopped operating (y/n)" + ret = self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + if ret != "y": + for p in new_progress_list: + if p.areaID == new_current_area: + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kOperating, + "Progress for areaID({new_current_area}) should be Operating") + break + + was_only_skipped_or_completed = True + for p in old_progress_list: + if p.areaID != old_current_area: + if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + Clusters.ServiceArea.OperationalStatusEnum.kCompleted): + was_only_skipped_or_completed = False + break + if was_only_skipped_or_completed: + asserts.assert_true(ret == "y", "The device should not be operating") + self.print_step("17", "") return + + if self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): + test_step = "Manually intervene to put the device in a state that allows it to execute the SkipArea command" + self.print_step("18", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - if self.check_pics("SEAR.S.M.VALID_STATE_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): - test_step = "Manually intervene to put the device in a state that allows it to execute the SkipArea command" - self.print_step("18", test_step) - if not self.is_ci: - self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - + if self.check_pics("SEAR.S.A0005"): self.print_step("19", "") if len(old_progress_list) == 0: return - + area_to_skip = NullValue self.print_step("20", "") for p in old_progress_list: @@ -234,41 +233,41 @@ async def test_TC_SEAR_1_5(self): if area_to_skip is NullValue: return - await self.send_cmd_skip_area_expect_response(step=21, skipped_area=area_to_skip, expected_response=Clusters.ServiceArea.SkipAreaStatus.kSuccess) + await self.send_cmd_skip_area_expect_response(step=21, skipped_area=area_to_skip, + expected_response=Clusters.ServiceArea.SkipAreaStatus.kSuccess) - test_step = "(Manual operation) wait for the device to update Progress or to stop operating" - self.print_step("22", test_step) - if not self.is_ci: - self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + test_step = "(Manual operation) wait for the device to update Progress or to stop operating" + self.print_step("22", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - if self.check_pics("SEAR.S.A0005"): - new_progress_list = await self.read_progress(step=23) - asserts.assert_true(len(new_progress_list) > 0, f"len of Progress({len(new_progress_list)}) should not be zero)") + if self.check_pics("SEAR.S.A0005"): + new_progress_list = await self.read_progress(step=23) + asserts.assert_true(len(new_progress_list) > 0, f"len of Progress({len(new_progress_list)}) should not be zero)") - for p in new_progress_list: - if p.areaID == area_to_skip: - asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, - "Progress for areaID({new_current_area}) should be Skipped") - break + for p in new_progress_list: + if p.areaID == area_to_skip: + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + "Progress for areaID({new_current_area}) should be Skipped") + break - test_step = "Indicate whether the device has stopped operating (y/n)" - ret = self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - - if ret != "y": - was_only_skipped_or_completed = True - for p in old_progress_list: - if p.areaID != area_to_skip: - if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped, - Clusters.ServiceArea.OperationalStatusEnum.kCompleted): - was_only_skipped_or_completed = False - break - if was_only_skipped_or_completed: - for p in new_progress_list: - if p.areaID == old_current_area: - asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, - "Progress for areaID({old_current_area}) should be Skipped") - break + test_step = "Indicate whether the device has stopped operating (y/n)" + ret = self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + was_only_skipped_or_completed = True + for p in old_progress_list: + if p.areaID != area_to_skip: + if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + Clusters.ServiceArea.OperationalStatusEnum.kCompleted): + was_only_skipped_or_completed = False + break + if was_only_skipped_or_completed: + asserts.assert_true(ret == "y", "The device should not be operating") + for p in new_progress_list: + if p.areaID == old_current_area: + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + "Progress for areaID({old_current_area}) should be Skipped") + break if __name__ == "__main__": default_matter_test_main() diff --git a/src/python_testing/TC_SEAR_1_6.py b/src/python_testing/TC_SEAR_1_6.py index 4324e4415ea211..d284bf6d8b6a3b 100644 --- a/src/python_testing/TC_SEAR_1_6.py +++ b/src/python_testing/TC_SEAR_1_6.py @@ -53,10 +53,7 @@ async def read_supported_areas(self, step): endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SupportedAreas) logging.info("SupportedAreas: %s" % (supported_areas)) - areaid_list = [] - for a in supported_areas: - areaid_list.append(a.areaID) - return areaid_list + return [a.areaID for a in supported_areas] async def read_selected_areas(self, step): self.print_step(step, "Read SelectedAreas attribute") @@ -64,10 +61,7 @@ async def read_selected_areas(self, step): endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SelectedAreas) logging.info(f"SelectedAreas {selected_areas}") - selareaid_list = [] - for a in selected_areas: - selareaid_list.append(a.areaID) - return selareaid_list + return selected_areas async def read_progress(self, step): self.print_step(step, "Read Progress attribute") @@ -86,7 +80,7 @@ def write_to_app_pipe(self, command): sleep(0.001) def TC_SEAR_1_6(self) -> list[str]: - return ["SEAR.S", "SEAR.S.A0005", "SEAR.S.M.HAS_MANUAL_OPERATING_STATE_CONTROL"] + return ["SEAR.S", "SEAR.S.A0005", "SEAR.S.A0000", "SEAR.S.A0002", "SEAR.S.M.HAS_MANUAL_OPERATING_STATE_CONTROL"] @async_test_body async def test_TC_SEAR_1_6(self): @@ -106,7 +100,7 @@ async def test_TC_SEAR_1_6(self): self.write_to_app_pipe('{"Name": "Reset"}') #FIXME is this necesssary? I'm not sure what TC_SEAR_1_6() is used for - if not (self.check_pics("SEAR.S.A0005") and self.check_pics("SEAR.S.M.HAS_MANUAL_OPERATING_STATE_CONTROL")): + if not self.check_pics("SEAR.S.A0005"): return test_step = "Manually intervene to put the device in the idle state and ensure SupportedAreas and SelectedAreas are not empty" From e4645eea34ab1c17e6865344c1fd7e80f6f79be2 Mon Sep 17 00:00:00 2001 From: Petru Lauric <81822411+plauric@users.noreply.github.com> Date: Wed, 31 Jul 2024 09:40:13 -0400 Subject: [PATCH 11/15] Update src/python_testing/TC_SEAR_1_2.py Co-authored-by: Kiel Oleson --- src/python_testing/TC_SEAR_1_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_SEAR_1_2.py b/src/python_testing/TC_SEAR_1_2.py index eb1cdaea4be335..23ac0c68284d8e 100644 --- a/src/python_testing/TC_SEAR_1_2.py +++ b/src/python_testing/TC_SEAR_1_2.py @@ -15,7 +15,7 @@ # limitations under the License. # -# TODO - this was copied/pasted from abother test, it needs to be reviewed and updated +# TODO - this was copied/pasted from another test, it needs to be reviewed and updated # See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments # for details about the block below. # From 7d9d4a179700a255342a654dc0e6697c04833a9a Mon Sep 17 00:00:00 2001 From: Petru Lauric Date: Wed, 31 Jul 2024 11:31:47 -0400 Subject: [PATCH 12/15] address code review feedback --- src/python_testing/TC_SEAR_1_2.py | 19 +++----- src/python_testing/TC_SEAR_1_3.py | 2 +- src/python_testing/TC_SEAR_1_5.py | 77 ++++++++++++++++--------------- 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/python_testing/TC_SEAR_1_2.py b/src/python_testing/TC_SEAR_1_2.py index 23ac0c68284d8e..f9c55a66028f10 100644 --- a/src/python_testing/TC_SEAR_1_2.py +++ b/src/python_testing/TC_SEAR_1_2.py @@ -63,18 +63,13 @@ async def read_and_validate_supported_maps(self, step): logging.info("SupportedMaps: %s" % (supported_maps)) asserts.assert_less_equal(len(supported_maps), 255, "SupportedMaps should have max 255 entries") - mapid_list = [] - for m in supported_maps: - if m.mapID in mapid_list: - asserts.fail("SupportedMaps must have unique MapID values!") - else: - mapid_list.append(m.mapID) - name_list = [] - for m in supported_maps: - if m.name in name_list: - asserts.fail("SupportedMaps must have unique Name values!") - else: - name_list.append(m.name) + + mapid_list = [m.mapID for m in supported_maps] + asserts.assert_true(len(set(mapid_list)) == len(mapid_list), "SupportedMaps must have unique MapID values!") + + name_list = [m.name for m in supported_maps] + asserts.assert_true(len(set(name_list)) == len(name_list), "SupportedMaps must have unique Name values!") + #save so other methods can use this if neeeded self.mapid_list = mapid_list diff --git a/src/python_testing/TC_SEAR_1_3.py b/src/python_testing/TC_SEAR_1_3.py index 94eb89f6dfaf20..b812af4a10afac 100644 --- a/src/python_testing/TC_SEAR_1_3.py +++ b/src/python_testing/TC_SEAR_1_3.py @@ -61,7 +61,7 @@ async def read_selected_areas(self, step): endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SelectedAreas) logging.info(f"SelectedAreas {selected_areas}") - return [a.areaID for a in selected_areas] + return selected_areas async def send_cmd_select_areas_expect_response(self, step, new_areas, expected_response): self.print_step(step, f"Send SelectAreas command with NewAreas({new_areas})") diff --git a/src/python_testing/TC_SEAR_1_5.py b/src/python_testing/TC_SEAR_1_5.py index 043465fcb735c4..23fc9101278d53 100644 --- a/src/python_testing/TC_SEAR_1_5.py +++ b/src/python_testing/TC_SEAR_1_5.py @@ -169,47 +169,52 @@ async def test_TC_SEAR_1_5(self): if old_current_area is not NullValue: await self.send_cmd_skip_area_expect_response(step=13, skipped_area=old_current_area, expected_response=Clusters.ServiceArea.SkipAreaStatus.kSuccess) - if self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): - test_step = "(Manual operation) wait for the device to skip the current area, and start operating at\ - the next one it should process, or stop operating" - self.print_step("14", test_step) - if not self.is_ci: - self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + if self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): + test_step = "(Manual operation) wait for the device to skip the current area, and start operating at\ + the next one it should process, or stop operating" + self.print_step("14", test_step) + if not self.is_ci: + self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - if self.check_pics("SEAR.S.A0005"): - new_progress_list = await self.read_progress(step=15) - asserts.assert_true(len(new_progress_list) > 0, f"len of Progress({len(new_progress_list)}) should not be zero)") + if self.check_pics("SEAR.S.A0005"): + new_progress_list = await self.read_progress(step=15) + asserts.assert_true(len(new_progress_list) > 0, f"len of Progress({len(new_progress_list)}) should not be zero)") - new_current_area = NullValue - if self.check_pics("SEAR.S.A0003"): - new_current_area = await self.read_current_area(step=16) - for p in new_progress_list: - if p.areaID == old_current_area: - asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, - "Progress for areaID({old_current_area}) should be Skipped") - break - test_step = "Indicate whether the device has stopped operating (y/n)" - ret = self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + prog_areas = [p.areaID for p in new_progress_list] - if ret != "y": - for p in new_progress_list: - if p.areaID == new_current_area: - asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kOperating, - "Progress for areaID({new_current_area}) should be Operating") - break + asserts.assert_true(old_current_area in prog_areas, f"Progress should include area {old_current_area}") - was_only_skipped_or_completed = True - for p in old_progress_list: - if p.areaID != old_current_area: - if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped, - Clusters.ServiceArea.OperationalStatusEnum.kCompleted): - was_only_skipped_or_completed = False + new_current_area = await self.read_current_area(step=16) + for p in new_progress_list: + if p.areaID == old_current_area: + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + "Progress for areaID({old_current_area}) should be Skipped") break - if was_only_skipped_or_completed: - asserts.assert_true(ret == "y", "The device should not be operating") - - self.print_step("17", "") - return + test_step = "Indicate whether the device has stopped operating (y/n)" + ret = self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + # Verify that if the device hasn't stopped operating, the `new_progress_list`'s entry matching `new_current_area` shows the Operating status + if ret != "y": + for p in new_progress_list: + if p.areaID == new_current_area: + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kOperating, + "Progress for areaID({new_current_area}) should be Operating") + break + + # next, we need to check for something else (so the condition of the 'if' above becomes part of the 'then' statement below): + # if before skipping all areas, except the current one, were Skipped or Completed, the device MUST have stopped operating + was_only_skipped_or_completed = True + for p in old_progress_list: + if p.areaID != old_current_area: + if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + Clusters.ServiceArea.OperationalStatusEnum.kCompleted): + was_only_skipped_or_completed = False + break + if was_only_skipped_or_completed: + asserts.assert_true(ret == "y", "The device should not be operating") + + self.print_step("17", "") + return if self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): test_step = "Manually intervene to put the device in a state that allows it to execute the SkipArea command" From 0562092a1cf84a20cbc8df13551b28f02f2a61a5 Mon Sep 17 00:00:00 2001 From: Petru Lauric Date: Wed, 31 Jul 2024 11:37:24 -0400 Subject: [PATCH 13/15] remove PICS checked by the TC_SEAR_1.6 --- src/python_testing/TC_SEAR_1_6.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/python_testing/TC_SEAR_1_6.py b/src/python_testing/TC_SEAR_1_6.py index d284bf6d8b6a3b..53dd6aecaa7f90 100644 --- a/src/python_testing/TC_SEAR_1_6.py +++ b/src/python_testing/TC_SEAR_1_6.py @@ -98,10 +98,6 @@ async def test_TC_SEAR_1_6(self): # Ensure that the device is in the correct state if self.is_ci: self.write_to_app_pipe('{"Name": "Reset"}') - - #FIXME is this necesssary? I'm not sure what TC_SEAR_1_6() is used for - if not self.check_pics("SEAR.S.A0005"): - return test_step = "Manually intervene to put the device in the idle state and ensure SupportedAreas and SelectedAreas are not empty" self.print_step("2", test_step) From 6ec55f1d97121d059649e1318582fdd6a7e7978e Mon Sep 17 00:00:00 2001 From: Petru Lauric Date: Wed, 31 Jul 2024 11:48:25 -0400 Subject: [PATCH 14/15] more code review updates --- src/python_testing/TC_SEAR_1_5.py | 90 ++++++++++++++++--------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/src/python_testing/TC_SEAR_1_5.py b/src/python_testing/TC_SEAR_1_5.py index 23fc9101278d53..f189b7bb9d3bc8 100644 --- a/src/python_testing/TC_SEAR_1_5.py +++ b/src/python_testing/TC_SEAR_1_5.py @@ -216,63 +216,65 @@ async def test_TC_SEAR_1_5(self): self.print_step("17", "") return + if not self.check_pics("SEAR.S.A0005"): + return + if self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): test_step = "Manually intervene to put the device in a state that allows it to execute the SkipArea command" self.print_step("18", test_step) if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - if self.check_pics("SEAR.S.A0005"): - self.print_step("19", "") - if len(old_progress_list) == 0: - return - - area_to_skip = NullValue - self.print_step("20", "") - for p in old_progress_list: - if p.status in (Clusters.ServiceArea.OperationalStatusEnum.kPending, - Clusters.ServiceArea.OperationalStatusEnum.kOperating): - area_to_skip = p.areaID - break - - if area_to_skip is NullValue: - return + self.print_step("19", "") + if len(old_progress_list) == 0: + return + + area_to_skip = NullValue + self.print_step("20", "") + for p in old_progress_list: + if p.status in (Clusters.ServiceArea.OperationalStatusEnum.kPending, + Clusters.ServiceArea.OperationalStatusEnum.kOperating): + area_to_skip = p.areaID + break + + if area_to_skip is NullValue: + return - await self.send_cmd_skip_area_expect_response(step=21, skipped_area=area_to_skip, - expected_response=Clusters.ServiceArea.SkipAreaStatus.kSuccess) + await self.send_cmd_skip_area_expect_response(step=21, skipped_area=area_to_skip, + expected_response=Clusters.ServiceArea.SkipAreaStatus.kSuccess) + if self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): test_step = "(Manual operation) wait for the device to update Progress or to stop operating" self.print_step("22", test_step) if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - if self.check_pics("SEAR.S.A0005"): - new_progress_list = await self.read_progress(step=23) - asserts.assert_true(len(new_progress_list) > 0, f"len of Progress({len(new_progress_list)}) should not be zero)") - - for p in new_progress_list: - if p.areaID == area_to_skip: - asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, - "Progress for areaID({new_current_area}) should be Skipped") - break - - test_step = "Indicate whether the device has stopped operating (y/n)" - ret = self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - - was_only_skipped_or_completed = True - for p in old_progress_list: - if p.areaID != area_to_skip: - if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped, - Clusters.ServiceArea.OperationalStatusEnum.kCompleted): - was_only_skipped_or_completed = False - break - if was_only_skipped_or_completed: - asserts.assert_true(ret == "y", "The device should not be operating") - for p in new_progress_list: - if p.areaID == old_current_area: - asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, - "Progress for areaID({old_current_area}) should be Skipped") - break + new_progress_list = await self.read_progress(step=23) + asserts.assert_true(len(new_progress_list) > 0, f"len of Progress({len(new_progress_list)}) should not be zero)") + + for p in new_progress_list: + if p.areaID == area_to_skip: + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + "Progress for areaID({new_current_area}) should be Skipped") + break + + test_step = "Indicate whether the device has stopped operating (y/n)" + ret = self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") + + was_only_skipped_or_completed = True + for p in old_progress_list: + if p.areaID != area_to_skip: + if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + Clusters.ServiceArea.OperationalStatusEnum.kCompleted): + was_only_skipped_or_completed = False + break + if was_only_skipped_or_completed: + asserts.assert_true(ret == "y", "The device should not be operating") + for p in new_progress_list: + if p.areaID == old_current_area: + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + "Progress for areaID({old_current_area}) should be Skipped") + break if __name__ == "__main__": default_matter_test_main() From fee9906cab125b559da837ba5b8f475e762c1d7d Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 31 Jul 2024 15:49:30 +0000 Subject: [PATCH 15/15] Restyled by autopep8 --- src/python_testing/TC_SEAR_1_2.py | 88 +++++++++++++++---------------- src/python_testing/TC_SEAR_1_3.py | 10 ++-- src/python_testing/TC_SEAR_1_4.py | 9 ++-- src/python_testing/TC_SEAR_1_5.py | 43 ++++++++------- src/python_testing/TC_SEAR_1_6.py | 15 +++--- 5 files changed, 86 insertions(+), 79 deletions(-) diff --git a/src/python_testing/TC_SEAR_1_2.py b/src/python_testing/TC_SEAR_1_2.py index f9c55a66028f10..4ebb3342ee9bfc 100644 --- a/src/python_testing/TC_SEAR_1_2.py +++ b/src/python_testing/TC_SEAR_1_2.py @@ -45,13 +45,12 @@ def __init__(self, *args): self.app_pipe = "/tmp/chip_rvc_fifo_" self.mapid_list = [] - #this must be kept in sync with the definitions from the Common Landmark Semantic Tag Namespace + # this must be kept in sync with the definitions from the Common Landmark Semantic Tag Namespace self.MAX_LANDMARK_ID = 0x33 - #this must be kept in sync with the definitions from the Common Relative Position Semantic Tag Namespace + # this must be kept in sync with the definitions from the Common Relative Position Semantic Tag Namespace self.MAX_RELPOS_ID = 0x07 - async def read_sear_attribute_expect_success(self, endpoint, attribute): cluster = Clusters.Objects.ServiceArea return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) @@ -62,15 +61,15 @@ async def read_and_validate_supported_maps(self, step): endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SupportedMaps) logging.info("SupportedMaps: %s" % (supported_maps)) asserts.assert_less_equal(len(supported_maps), 255, - "SupportedMaps should have max 255 entries") - + "SupportedMaps should have max 255 entries") + mapid_list = [m.mapID for m in supported_maps] asserts.assert_true(len(set(mapid_list)) == len(mapid_list), "SupportedMaps must have unique MapID values!") name_list = [m.name for m in supported_maps] asserts.assert_true(len(set(name_list)) == len(name_list), "SupportedMaps must have unique Name values!") - #save so other methods can use this if neeeded + # save so other methods can use this if neeeded self.mapid_list = mapid_list async def read_and_validate_supported_areas(self, step): @@ -79,38 +78,40 @@ async def read_and_validate_supported_areas(self, step): endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SupportedAreas) logging.info("SupportedAreas: %s" % (supported_areas)) asserts.assert_less_equal(len(supported_areas), 255, - "SupportedAreas should have max 255 entries") + "SupportedAreas should have max 255 entries") areaid_list = [] areadesc_s = set() for a in supported_areas: asserts.assert_true(a.areaID not in areaid_list, "SupportedAreas must have unique AreaID values!") areaid_list.append(a.areaID) - + if len(self.mapid_list) > 0: asserts.assert_is_not(a.mapID, NullValue, - f"SupportedAreas entry with AreaID({a.areaID}) should not have null MapID") + f"SupportedAreas entry with AreaID({a.areaID}) should not have null MapID") asserts.assert_is(a.mapID in self.mapid_list, - f"SupportedAreas entry with AreaID({a.areaID}) has unknown MapID({a.mapID})") + f"SupportedAreas entry with AreaID({a.areaID}) has unknown MapID({a.mapID})") k = f"mapID:{a.mapID} areaDesc:{a.areaDesc}" - asserts.assert_true(k not in areadesc_s, f"SupportedAreas must have unique MapID({a.mapID}) + AreaDesc({a.areaDesc}) values!") + asserts.assert_true(k not in areadesc_s, + f"SupportedAreas must have unique MapID({a.mapID}) + AreaDesc({a.areaDesc}) values!") areadesc_s.add(k) else: - #empty SupportedMaps + # empty SupportedMaps asserts.assert_is(a.mapID, NullValue, - f"SupportedAreas entry with AreaID({a.areaID}) should have null MapID") + f"SupportedAreas entry with AreaID({a.areaID}) should have null MapID") k = f"areaDesc:{a.areaDesc}" asserts.assert_true(k not in areadesc_s, f"SupportedAreas must have unique AreaDesc({a.areaDesc}) values!") areadesc_s.add(k) if a.locationInfo is NullValue and a.landmarkTag is NullValue: - asserts.assert_true(f"SupportedAreas entry with AreaID({a.areaID}) should not have null LocationInfo and null LandmarkTag") + asserts.assert_true( + f"SupportedAreas entry with AreaID({a.areaID}) should not have null LocationInfo and null LandmarkTag") if a.landmarkTag is not NullValue: asserts.assert_true(a.landmarkTag <= self.MAX_LANDMARK_ID, - f"SupportedAreas entry with AreaID({a.areaID}) has invalid LandmarkTag({a.landmarkTag})") + f"SupportedAreas entry with AreaID({a.areaID}) has invalid LandmarkTag({a.landmarkTag})") asserts.assert_true(a.positionTag is NullValue or a.positionTag in range(0, self.MAX_RELPOS_ID), - f"SupportedAreas entry with AreaID({a.areaID}) has invalid PositionTag({a.positionTag})") - #save so other methods can use this if neeeded + f"SupportedAreas entry with AreaID({a.areaID}) has invalid PositionTag({a.positionTag})") + # save so other methods can use this if neeeded self.areaid_list = areaid_list async def read_and_validate_selected_areas(self, step): @@ -119,17 +120,17 @@ async def read_and_validate_selected_areas(self, step): endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SelectedAreas) logging.info(f"SelectedAreas {selected_areas}") - #TODO how to check if all entries are uint32? + # TODO how to check if all entries are uint32? asserts.assert_true(len(selected_areas) <= len(self.areaid_list), - f"SelectedAreas(len {len(selected_areas)}) should have at most {len(self.areaid_list)} entries") + f"SelectedAreas(len {len(selected_areas)}) should have at most {len(self.areaid_list)} entries") asserts.assert_true(len(set(selected_areas)) == len(selected_areas), "SelectedAreas must have unique AreaID values!") - - for a in selected_areas: + + for a in selected_areas: asserts.assert_true(a in self.areaid_list, - f"SelectedAreas entry {a} has invalid value") - #save so other methods can use this if neeeded + f"SelectedAreas entry {a} has invalid value") + # save so other methods can use this if neeeded self.selareaid_list = selected_areas async def read_and_validate_current_area(self, step): @@ -139,12 +140,12 @@ async def read_and_validate_current_area(self, step): logging.info(f"CurrentArea {current_area}") asserts.assert_true((len(self.selareaid_list) == 0 and current_area is NullValue) - or - current_area in self.selareaid_list, - f"CurrentArea {current_area} is invalid. SelectedAreas is {self.selareaid_list}.") - #save so other methods can use this if neeeded + or + current_area in self.selareaid_list, + f"CurrentArea {current_area} is invalid. SelectedAreas is {self.selareaid_list}.") + # save so other methods can use this if neeeded self.current_area = current_area - + async def read_and_validate_estimated_end_time(self, step): import time read_time = int(time.time()) @@ -155,13 +156,12 @@ async def read_and_validate_estimated_end_time(self, step): if self.current_area is NullValue: asserts.assert_true(estimated_end_time is NullValue, - "EstimatedEndTime should be null if CurrentArea is null.") + "EstimatedEndTime should be null if CurrentArea is null.") else: - #allow for some clock skew + # allow for some clock skew asserts.assert_true(estimated_end_time >= read_time - 3*60, - f"EstimatedEndTime({estimated_end_time}) should be greater than the time when it was read({read_time})") + f"EstimatedEndTime({estimated_end_time}) should be greater than the time when it was read({read_time})") - async def read_and_validate_progress(self, step): self.print_step(step, "Read Progress attribute") progress = await self.read_sear_attribute_expect_success( @@ -169,7 +169,7 @@ async def read_and_validate_progress(self, step): logging.info(f"Progress {progress}") asserts.assert_true(len(progress) <= len(self.areaid_list), - f"Progress(len {len(progress)}) should have at most {len(self.areaid_list)} entries") + f"Progress(len {len(progress)}) should have at most {len(self.areaid_list)} entries") progareaid_list = [] for p in progress: @@ -178,16 +178,16 @@ async def read_and_validate_progress(self, step): else: progareaid_list.append(p.areaID) asserts.assert_true(p.areaID in self.areaid_list, - f"Progress entry has invalid AreaID value ({p.areaID})") + f"Progress entry has invalid AreaID value ({p.areaID})") asserts.assert_true(p.status in (Clusters.ServiceArea.OperationalStatusEnum.kPending, Clusters.ServiceArea.OperationalStatusEnum.kOperating, Clusters.ServiceArea.OperationalStatusEnum.kSkipped, Clusters.ServiceArea.OperationalStatusEnum.kCompleted), - f"Progress entry has invalid Status value ({p.status})") + f"Progress entry has invalid Status value ({p.status})") if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped, Clusters.ServiceArea.OperationalStatusEnum.kCompleted): - asserts.assert_true(p.totalOperationalTime is NullValue, - f"Progress entry should have a null TotalOperationalTime value (Status is {p.status})") - #TODO how to check that InitialTimeEstimate is either null or uint32? + asserts.assert_true(p.totalOperationalTime is NullValue, + f"Progress entry should have a null TotalOperationalTime value (Status is {p.status})") + # TODO how to check that InitialTimeEstimate is either null or uint32? # Sends and out-of-band command to the rvc-app def write_to_app_pipe(self, command): @@ -251,7 +251,7 @@ async def test_TC_SEAR_1_2(self): new_supported_maps = self.mapid_list asserts.assert_true(len(old_supported_maps) > len(new_supported_maps), "Failed to remove map(s)") - #NOTE the following operations are all part of step 11 - read all these attributes and check the data consistency + # NOTE the following operations are all part of step 11 - read all these attributes and check the data consistency # after removing map(s) await self.read_and_validate_supported_areas(step=11) @@ -284,7 +284,7 @@ async def test_TC_SEAR_1_2(self): new_supported_maps = self.mapid_list asserts.assert_true(len(old_supported_maps) < len(new_supported_maps), "Failed to add map(s)") - #NOTE the following operations are all part of step 15 - read all these attributes and check the data consistency + # NOTE the following operations are all part of step 15 - read all these attributes and check the data consistency # after adding map(s) await self.read_and_validate_supported_areas(step=15) @@ -317,9 +317,9 @@ async def test_TC_SEAR_1_2(self): new_supported_areas = self.areaid_list asserts.assert_true(len(old_supported_areas) > len(new_supported_areas), "Failed to remove area(s)") - #NOTE the following operations are all part of step 19 - read all these attributes and check the data consistency + # NOTE the following operations are all part of step 19 - read all these attributes and check the data consistency # after removing areas(s) - + await self.read_and_validate_selected_areas(step=19) if self.check_pics("SEAR.S.A0003"): @@ -349,9 +349,9 @@ async def test_TC_SEAR_1_2(self): new_supported_areas = self.areaid_list asserts.assert_true(len(old_supported_areas) < len(new_supported_areas), "Failed to add area(s)") - #NOTE the following operations are all part of step 23 - read all these attributes and check the data consistency + # NOTE the following operations are all part of step 23 - read all these attributes and check the data consistency # after removing areas(s) - + await self.read_and_validate_selected_areas(step=23) if self.check_pics("SEAR.S.A0003"): diff --git a/src/python_testing/TC_SEAR_1_3.py b/src/python_testing/TC_SEAR_1_3.py index b812af4a10afac..0acee1b34cdeb8 100644 --- a/src/python_testing/TC_SEAR_1_3.py +++ b/src/python_testing/TC_SEAR_1_3.py @@ -62,12 +62,12 @@ async def read_selected_areas(self, step): logging.info(f"SelectedAreas {selected_areas}") return selected_areas - + async def send_cmd_select_areas_expect_response(self, step, new_areas, expected_response): self.print_step(step, f"Send SelectAreas command with NewAreas({new_areas})") ret = await self.send_single_cmd(cmd=Clusters.Objects.ServiceArea.Commands.SelectAreas(newAreas=new_areas), endpoint=self.endpoint) - + asserts.assert_equal(ret.commandResponseState.errorStateID, expected_response, f"Command response ({ret.commandResponseState}) doesn't match the expected one") @@ -107,7 +107,7 @@ async def test_TC_SEAR_1_3(self): duplicated_areas = [valid_area_id, valid_area_id] - #FIXME need to check if this is the correct name of this status code + # FIXME need to check if this is the correct name of this status code await self.send_cmd_select_areas_expect_response(step=3, new_areas=duplicated_areas, expected_response=Clusters.ServiceArea.SelectAreasStatus.kDuplicatedAreas) await self.send_cmd_select_areas_expect_response(step=4, new_areas=[], expected_response=Clusters.ServiceArea.SelectAreasStatus.kSuccess) @@ -134,7 +134,8 @@ async def test_TC_SEAR_1_3(self): await self.send_cmd_select_areas_expect_response(step=10, new_areas=supported_area_ids, expected_response=Clusters.ServiceArea.SelectAreasStatus.kSuccess) selected_areas = await self.read_selected_areas(step=11) - asserts.assert_true(len(selected_areas) == len(supported_area_ids), f"SelectedAreas({selected_areas}) should match SupportedAreas({supported_area_ids})") + asserts.assert_true(len(selected_areas) == len(supported_area_ids), + f"SelectedAreas({selected_areas}) should match SupportedAreas({supported_area_ids})") await self.send_cmd_select_areas_expect_response(step=12, new_areas=supported_area_ids, expected_response=Clusters.ServiceArea.SelectAreasStatus.kSuccess) @@ -150,6 +151,5 @@ async def test_TC_SEAR_1_3(self): await self.send_cmd_select_areas_expect_response(step=14, new_areas=[valid_area_id], expected_response=Clusters.ServiceArea.SelectAreasStatus.kInvalidInMode) - if __name__ == "__main__": default_matter_test_main() diff --git a/src/python_testing/TC_SEAR_1_4.py b/src/python_testing/TC_SEAR_1_4.py index dffdda0db67734..a6326559beaa20 100644 --- a/src/python_testing/TC_SEAR_1_4.py +++ b/src/python_testing/TC_SEAR_1_4.py @@ -71,12 +71,13 @@ async def test_TC_SEAR_1_4(self): logging.info("AttributeList: %s" % (attribute_list)) if Clusters.ServiceArea.Attributes.CurrentArea not in attribute_list \ - and Clusters.ServiceArea.Attributes.Progress not in attribute_list: - + and Clusters.ServiceArea.Attributes.Progress not in attribute_list: + cmd_list = await self.read_sear_attribute_expect_success( - endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.AcceptedCommandList) + endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.AcceptedCommandList) logging.info("AcceptedCommandList: %s" % (cmd_list)) - asserts.assert_true(Clusters.ServiceArea.Commands.SkipArea not in cmd_list, "SkipArea command should not be implemented if both CurrentArea and Progress are not") + asserts.assert_true(Clusters.ServiceArea.Commands.SkipArea not in cmd_list, + "SkipArea command should not be implemented if both CurrentArea and Progress are not") if __name__ == "__main__": diff --git a/src/python_testing/TC_SEAR_1_5.py b/src/python_testing/TC_SEAR_1_5.py index f189b7bb9d3bc8..adcf8341c93389 100644 --- a/src/python_testing/TC_SEAR_1_5.py +++ b/src/python_testing/TC_SEAR_1_5.py @@ -36,6 +36,7 @@ from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main from mobly import asserts + class TC_SEAR_1_5(MatterBaseTest): def __init__(self, *args): super().__init__(*args) @@ -83,13 +84,13 @@ async def send_cmd_skip_area_expect_response(self, step, skipped_area, expected_ self.print_step(step, f"Send SkipArea command with SkippedArea({skipped_area})") ret = await self.send_single_cmd(cmd=Clusters.Objects.ServiceArea.Commands.SkipArea(skippedArea=skipped_area), endpoint=self.endpoint) - + asserts.assert_equal(ret.commandResponseState.errorStateID, expected_response, f"Command response ({ret.commandResponseState}) doesn't match the expected one") - # Sends and out-of-band command to the rvc-app + def write_to_app_pipe(self, command): with open(self.app_pipe, "w") as app_pipe: app_pipe.write(command + "\n") @@ -128,8 +129,8 @@ async def test_TC_SEAR_1_5(self): self.print_step("3", test_step) if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - - await self.send_cmd_skip_area_expect_response(step=4, skipped_area=valid_area_id, + + await self.send_cmd_skip_area_expect_response(step=4, skipped_area=valid_area_id, expected_response=Clusters.ServiceArea.SkipAreaStatus.kInvalidInMode) if self.check_pics("SEAR.S.M.NO_SELAREA_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): @@ -138,7 +139,7 @@ async def test_TC_SEAR_1_5(self): self.print_step("5", test_step) if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - + await self.send_cmd_skip_area_expect_response(step=6, skipped_area=valid_area_id, expected_response=Clusters.ServiceArea.SkipAreaStatus.kInvalidAreaList) @@ -147,13 +148,13 @@ async def test_TC_SEAR_1_5(self): self.print_step("7", test_step) if not self.is_ci: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - + await self.send_cmd_skip_area_expect_response(step=8, skipped_area=invalid_area_id, expected_response=Clusters.ServiceArea.SkipAreaStatus.kInvalidSkippedArea) if not self.check_pics("SEAR.S.M.VALID_STATE_FOR_SKIP"): return - + if self.check_pics("SEAR.S.A0005"): old_progress_list = await self.read_progress(step=9) asserts.assert_true(len(old_progress_list) > 0, f"len of Progress({len(old_progress_list)}) should not be zero)") @@ -178,7 +179,8 @@ async def test_TC_SEAR_1_5(self): if self.check_pics("SEAR.S.A0005"): new_progress_list = await self.read_progress(step=15) - asserts.assert_true(len(new_progress_list) > 0, f"len of Progress({len(new_progress_list)}) should not be zero)") + asserts.assert_true(len(new_progress_list) > 0, + f"len of Progress({len(new_progress_list)}) should not be zero)") prog_areas = [p.areaID for p in new_progress_list] @@ -187,7 +189,7 @@ async def test_TC_SEAR_1_5(self): new_current_area = await self.read_current_area(step=16) for p in new_progress_list: if p.areaID == old_current_area: - asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, "Progress for areaID({old_current_area}) should be Skipped") break test_step = "Indicate whether the device has stopped operating (y/n)" @@ -197,7 +199,7 @@ async def test_TC_SEAR_1_5(self): if ret != "y": for p in new_progress_list: if p.areaID == new_current_area: - asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kOperating, + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kOperating, "Progress for areaID({new_current_area}) should be Operating") break @@ -206,7 +208,7 @@ async def test_TC_SEAR_1_5(self): was_only_skipped_or_completed = True for p in old_progress_list: if p.areaID != old_current_area: - if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped, Clusters.ServiceArea.OperationalStatusEnum.kCompleted): was_only_skipped_or_completed = False break @@ -215,10 +217,10 @@ async def test_TC_SEAR_1_5(self): self.print_step("17", "") return - + if not self.check_pics("SEAR.S.A0005"): return - + if self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): test_step = "Manually intervene to put the device in a state that allows it to execute the SkipArea command" self.print_step("18", test_step) @@ -228,11 +230,11 @@ async def test_TC_SEAR_1_5(self): self.print_step("19", "") if len(old_progress_list) == 0: return - + area_to_skip = NullValue self.print_step("20", "") for p in old_progress_list: - if p.status in (Clusters.ServiceArea.OperationalStatusEnum.kPending, + if p.status in (Clusters.ServiceArea.OperationalStatusEnum.kPending, Clusters.ServiceArea.OperationalStatusEnum.kOperating): area_to_skip = p.areaID break @@ -241,7 +243,7 @@ async def test_TC_SEAR_1_5(self): return await self.send_cmd_skip_area_expect_response(step=21, skipped_area=area_to_skip, - expected_response=Clusters.ServiceArea.SkipAreaStatus.kSuccess) + expected_response=Clusters.ServiceArea.SkipAreaStatus.kSuccess) if self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): test_step = "(Manual operation) wait for the device to update Progress or to stop operating" @@ -254,7 +256,7 @@ async def test_TC_SEAR_1_5(self): for p in new_progress_list: if p.areaID == area_to_skip: - asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, "Progress for areaID({new_current_area}) should be Skipped") break @@ -264,7 +266,7 @@ async def test_TC_SEAR_1_5(self): was_only_skipped_or_completed = True for p in old_progress_list: if p.areaID != area_to_skip: - if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped, Clusters.ServiceArea.OperationalStatusEnum.kCompleted): was_only_skipped_or_completed = False break @@ -272,9 +274,10 @@ async def test_TC_SEAR_1_5(self): asserts.assert_true(ret == "y", "The device should not be operating") for p in new_progress_list: if p.areaID == old_current_area: - asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, - "Progress for areaID({old_current_area}) should be Skipped") + asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, + "Progress for areaID({old_current_area}) should be Skipped") break + if __name__ == "__main__": default_matter_test_main() diff --git a/src/python_testing/TC_SEAR_1_6.py b/src/python_testing/TC_SEAR_1_6.py index 53dd6aecaa7f90..02a0fcdd33133a 100644 --- a/src/python_testing/TC_SEAR_1_6.py +++ b/src/python_testing/TC_SEAR_1_6.py @@ -36,6 +36,7 @@ from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main from mobly import asserts + class TC_SEAR_1_6(MatterBaseTest): def __init__(self, *args): super().__init__(*args) @@ -98,7 +99,7 @@ async def test_TC_SEAR_1_6(self): # Ensure that the device is in the correct state if self.is_ci: self.write_to_app_pipe('{"Name": "Reset"}') - + test_step = "Manually intervene to put the device in the idle state and ensure SupportedAreas and SelectedAreas are not empty" self.print_step("2", test_step) if not self.is_ci: @@ -116,13 +117,14 @@ async def test_TC_SEAR_1_6(self): self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") progress_list_operating = await self.read_progress(step=6) - asserts.assert_true(len(selected_areas) == len(progress_list_operating), f"len of SelectedAreas({len(selected_areas)}) should be equal to len of Progress({len(progress_list_operating)})") + asserts.assert_true(len(selected_areas) == len(progress_list_operating), + f"len of SelectedAreas({len(selected_areas)}) should be equal to len of Progress({len(progress_list_operating)})") for p in progress_list_operating: asserts.assert_true(p.areaID in selected_areas, f"Progress entry with unknown AreaID({p.areaID})") asserts.assert_true(p.status in (Clusters.ServiceArea.OperationalStatusEnum.kPending, - Clusters.ServiceArea.OperationalStatusEnum.kOperating), - f"Progress entry with unexpected Status({p.status})") + Clusters.ServiceArea.OperationalStatusEnum.kOperating), + f"Progress entry with unexpected Status({p.status})") asserts.assert_true(p.TotalOperationalTime is NullValue, "Progress entry with non-null TotalOperationalTime") test_step = "While all entries in Progress show the Pending or Operating status (i.e. \ @@ -133,12 +135,13 @@ async def test_TC_SEAR_1_6(self): self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") progress_list_idle = await self.read_progress(step=8) - asserts.assert_true(len(selected_areas) == len(progress_list_idle), f"len of SelectedAreas({len(selected_areas)}) should be equal to len of Progress({len(progress_list_idle)})") + asserts.assert_true(len(selected_areas) == len(progress_list_idle), + f"len of SelectedAreas({len(selected_areas)}) should be equal to len of Progress({len(progress_list_idle)})") for p in progress_list_idle: asserts.assert_true(p.areaID in selected_areas, f"Progress entry with unknown AreaID({p.areaID})") asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped, - f"Progress entry with unexpected Status({p.status})") + f"Progress entry with unexpected Status({p.status})") if __name__ == "__main__":