Skip to content

Commit 3499f78

Browse files
committed
Add test script example for ECAL cluster
1 parent adc1a49 commit 3499f78

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

src/python_testing/TC_ECAL_25.py

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#
2+
# Copyright (c) 2022 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 logging
19+
20+
import chip.clusters as Clusters
21+
from chip.interaction_model import Status
22+
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
23+
from mobly import asserts
24+
25+
26+
class TC_ECAL_25(MatterBaseTest):
27+
async def read_ecal_attribute_expect_success(self, endpoint, attribute):
28+
cluster = Clusters.Objects.EnergyCalendar
29+
return await self.read_single_attribute_check_success(dev_ctrl=self.default_controller,
30+
node_id=self.dut_node_id,
31+
endpoint=endpoint,
32+
cluster=cluster,
33+
attribute=attribute)
34+
35+
async def read_ecal_calendar_id(self, endpoint=0):
36+
return await self.read_ecal_attribute_expect_success(endpoint, Clusters.EnergyCalendar.Attributes.CalendarID)
37+
38+
async def write_ecal_calendar_id(self, calendar_id, endpoint=0):
39+
# This returns an attribute status
40+
result = await self.default_controller.WriteAttribute(self.dut_node_id, [(endpoint, Clusters.EnergyCalendar.Attributes.CalendarID(calendar_id))])
41+
asserts.assert_equal(result[0].Status, Status.Success, "CalendarID write failed")
42+
43+
def desc_TC_ECAL_25(self) -> str:
44+
"""Returns a description of this test"""
45+
return "[TC-ECAL-25] CalendarID: valid value"
46+
47+
def steps_TC_ECAL_25(self) -> list[TestStep]:
48+
steps = [TestStep(1, "Commissioning, already done", is_commissioning=True),
49+
TestStep(2, "Set the attribute value to 0"),
50+
TestStep(3, "Read the attribute value"),
51+
TestStep(4, "Set the attribute value to 2147483648"),
52+
TestStep(5, "Read the attribute value"),
53+
TestStep(6, "Set the attribute value to 4294967294"),
54+
TestStep(7, "Read the attribute value"),
55+
TestStep(8, "Set the attribute value to 4294967295 (NULL)"),
56+
TestStep(9, "Read the attribute value")
57+
]
58+
return steps
59+
60+
@async_test_body
61+
async def test_TC_ECAL_25(self):
62+
self.step(1) # commissioning
63+
64+
self.step(2)
65+
await self.write_ecal_calendar_id(0)
66+
67+
self.step(3)
68+
await self.read_ecal_calendar_id()
69+
70+
self.step(4)
71+
await self.write_ecal_calendar_id(2147483648)
72+
73+
self.step(5)
74+
await self.read_ecal_calendar_id()
75+
76+
self.step(6)
77+
await self.write_ecal_calendar_id(4294967294)
78+
79+
self.step(7)
80+
await self.read_ecal_calendar_id()
81+
82+
self.step(8)
83+
await self.write_ecal_calendar_id(4294967295)
84+
85+
self.step(9)
86+
await self.read_ecal_calendar_id()
87+
88+
89+
if __name__ == "__main__":
90+
default_matter_test_main()

0 commit comments

Comments
 (0)