Skip to content

Commit 7f0b243

Browse files
tehampsonrestyled-commits
authored andcommitted
Add TC_ECOINFO_2_2.py test implementation (project-chip#34566)
* Add TC_ECOINFO_2_2.py test implementation * Restyled by autopep8 * Fix lint CI issues * Self review edits * One more minor nit edit * Restyled by autopep8 * Address TODO and add default_matter_test_main * Address PR comment * Restyled by autopep8 --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 69ef6f9 commit 7f0b243

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed

src/python_testing/TC_ECOINFO_2_2.py

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#
2+
# Copyright (c) 2024 Project CHIP Authors
3+
# All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
import chip.clusters as Clusters
19+
from chip.clusters.Types import NullValue
20+
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
21+
from mobly import asserts
22+
23+
_DEVICE_TYPE_AGGREGGATOR = 0x000E
24+
25+
26+
class TC_ECOINFO_2_2(MatterBaseTest):
27+
28+
def steps_TC_ECOINFO_2_2(self) -> list[TestStep]:
29+
steps = [TestStep(1, "Prepare", is_commissioning=True),
30+
TestStep("1a", "Read root endpoint's PartsList"),
31+
TestStep("1b", "For each endpoint in 1a read DeviceType list confirming aggregator endpoint exists"),
32+
TestStep(2, "Add a bridged device"),
33+
TestStep("2a", "(Manual Step) Add a bridged device using method indicated by the manufacturer"),
34+
TestStep("2b", "Read root endpoint's PartsList, validate exactly one endpoint added"),
35+
TestStep("2c", "On newly added endpoint detected in 2b read RemovedOn Ecosystem Information Attribute and validate"),
36+
TestStep(3, "Remove bridged device"),
37+
TestStep("3a", "(Manual Step) Removed bridged device added in step 2a using method indicated by the manufacturer"),
38+
TestStep("3b", "On newly added endpoint detected in 2b read RemovedOn Ecosystem Information Attribute and validate"),
39+
TestStep("3c", "On newly added endpoint detected in 2b read DeviceDirectory Ecosystem Information Attribute and validate"),
40+
TestStep("3d", "On newly added endpoint detected in 2b read LocationDirectory Ecosystem Information Attribute and validate")]
41+
42+
return steps
43+
44+
@async_test_body
45+
async def test_TC_ECOINFO_2_2(self):
46+
dev_ctrl = self.default_controller
47+
dut_node_id = self.dut_node_id
48+
49+
self.print_step(0, "Commissioning, already done")
50+
self.step(1)
51+
self.step("1a")
52+
root_node_endpoint = 0
53+
root_part_list = await dev_ctrl.ReadAttribute(dut_node_id, [(root_node_endpoint, Clusters.Descriptor.Attributes.PartsList)])
54+
55+
self.step("1b")
56+
set_of_endpoints_step_1 = set(root_part_list[root_node_endpoint]
57+
[Clusters.Descriptor][Clusters.Descriptor.Attributes.PartsList])
58+
list_of_aggregator_endpoints = []
59+
for endpoint in set_of_endpoints_step_1:
60+
device_type_list_read = await dev_ctrl.ReadAttribute(dut_node_id, [(endpoint, Clusters.Descriptor.Attributes.DeviceTypeList)])
61+
device_type_list = device_type_list_read[endpoint][Clusters.Descriptor][Clusters.Descriptor.Attributes.DeviceTypeList]
62+
for device_type in device_type_list:
63+
if device_type.deviceType == _DEVICE_TYPE_AGGREGGATOR:
64+
list_of_aggregator_endpoints.append(endpoint)
65+
66+
asserts.assert_greater_equal(len(list_of_aggregator_endpoints), 1, "Did not find any Aggregator device types")
67+
68+
self.step(2)
69+
self.step("2a")
70+
self.wait_for_user_input(prompt_msg="Add a bridged device using method indicated by the manufacturer")
71+
72+
self.step("2b")
73+
root_part_list_step_2 = await dev_ctrl.ReadAttribute(dut_node_id, [(root_node_endpoint, Clusters.Descriptor.Attributes.PartsList)])
74+
set_of_endpoints_step_2 = set(
75+
root_part_list_step_2[root_node_endpoint][Clusters.Descriptor][Clusters.Descriptor.Attributes.PartsList])
76+
77+
asserts.assert_true(set_of_endpoints_step_2.issuperset(set_of_endpoints_step_1), "Expected only new endpoints to be added")
78+
unique_endpoints_set = set_of_endpoints_step_2 - set_of_endpoints_step_1
79+
asserts.assert_equal(len(unique_endpoints_set), 1, "Expected only one new endpoint")
80+
81+
self.step("2c")
82+
newly_added_endpoint = list(unique_endpoints_set)[0]
83+
removed_on = await self.read_single_attribute(
84+
dev_ctrl,
85+
dut_node_id,
86+
endpoint=newly_added_endpoint,
87+
attribute=Clusters.EcosystemInformation.Attributes.RemovedOn)
88+
89+
asserts.assert_true(removed_on is NullValue, "RemovedOn is expected to be null for a newly added device")
90+
91+
self.step(3)
92+
self.step("3a")
93+
self.wait_for_user_input(prompt_msg="Removed bridged device added in step 2a using method indicated by the manufacturer")
94+
95+
self.step("3b")
96+
removed_on = await self.read_single_attribute(
97+
dev_ctrl,
98+
dut_node_id,
99+
endpoint=newly_added_endpoint,
100+
attribute=Clusters.EcosystemInformation.Attributes.RemovedOn)
101+
asserts.assert_true(removed_on is not NullValue, "RemovedOn is expected to have a value")
102+
103+
self.step("3c")
104+
device_directory = await self.read_single_attribute(
105+
dev_ctrl,
106+
dut_node_id,
107+
endpoint=newly_added_endpoint,
108+
attribute=Clusters.EcosystemInformation.Attributes.DeviceDirectory,
109+
fabricFiltered=False)
110+
asserts.assert_equal(len(device_directory), 0, "Expected device directory to be empty")
111+
112+
self.step("3d")
113+
location_directory = await self.read_single_attribute(
114+
dev_ctrl,
115+
dut_node_id,
116+
endpoint=newly_added_endpoint,
117+
attribute=Clusters.EcosystemInformation.Attributes.LocationDirectory,
118+
fabricFiltered=False)
119+
asserts.assert_equal(len(location_directory), 0, "Expected location directory to be empty")
120+
121+
122+
if __name__ == "__main__":
123+
default_matter_test_main()

0 commit comments

Comments
 (0)