Skip to content

Commit ef66cd8

Browse files
authored
TC-LTIME-3.1: Fix to not hard code calendars (project-chip#38824)
* TC-LTIME-3.1: Fix to not hard code calendars This was previously done from a PIXIT. Now it reads from the device and checks all. * make the get_endpoint call easier to read * Add test back into CI
1 parent 540cc2b commit ef66cd8

File tree

2 files changed

+55
-62
lines changed

2 files changed

+55
-62
lines changed

src/python_testing/TC_LTIME_3_1.py

Lines changed: 55 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -61,43 +61,35 @@ def steps_TC_LTIME_3_1(self) -> list[TestStep]:
6161
TestStep(0, "TH is commissioned with DUT", is_commissioning=True),
6262
TestStep(1, "TH reads HourFormat attribute from DUT",
6363
"Verify that the HourFormat attribute is of Enum8 datatype and that the values are 0 (12hr), 1 (24hr), and 255 (UseActiveLocale) as per the HourFormatEnum in the specification."),
64-
TestStep(2, "If (LTIME.S.M.12Hr) TH writes 0(12hr) to HourFormat attribute",
65-
"Verify that the write request is successful."),
66-
TestStep(3, "TH reads HourFormat attribute", "Verify that the value is 0 (12hr)."),
67-
TestStep(4, "If (LTIME.S.M.24Hr) TH writes 1(24hr) to HourFormat attribute",
68-
"Verify that the write request is successful."),
69-
TestStep(5, "TH reads HourFormat attribute", "Verify that the value is 1 (24hr)."),
70-
TestStep(6, "TH writes 255 (UseActiveLocale) to HourFormat attribute", "Verify that the write request is successful."),
71-
TestStep(7, "TH reads HourFormat attribute", "Verify that the value is 255 (UseActiveLocale)."),
72-
TestStep(8, "TH reads ActiveCalendarType attribute from DUT",
73-
"Verify that the ActiveCalendarType attribute is of Enum8 datatype and only accepts values 0-11 (specific calendar types) and 255 (UseActiveLocale), as defined in the CalendarTypeEnum in the specification."),
74-
TestStep(9, "TH writes value in PIXIT.LTIME.SCT to ActiveCalendarType attribute, followed by reading the ActiveCalendarType attribute value",
75-
"Verify that the write request is successful and that the read value matches the written value in previous step. as the value that was set before."),
76-
TestStep(10, "Repeat step 9 for all the values in PIXIT.LTIME.SCT",
77-
"Verify that the write request is successful and that the read value matches the written value."),
78-
TestStep(11, "TH reads SupportedCalendarTypes attribute from DUT",
64+
TestStep(2, "TH writes 0(12hr) to HourFormat attribute"),
65+
TestStep(3, "If the prior write was successful, TH reads HourFormat attribute", "Verify that the value is 0 (12hr)."),
66+
TestStep(4, "TH writes 1(24hr) to HourFormat attribute"),
67+
TestStep(5, "If the prior write was successful, TH reads HourFormat attribute", "Verify that the value is 1 (24hr)."),
68+
TestStep(6, "TH writes 255 (UseActiveLocale) to HourFormat attribute"),
69+
TestStep(7, "If the prior write was successful, TH reads HourFormat attribute",
70+
"Verify that the value is 255 (UseActiveLocale)."),
71+
TestStep(8, "TH reads SupportedCalendarTypes attribute from DUT and saves as `cluster_supported_calendar_types`",
7972
"Verify that the SupportedCalendarTypes attribute is of Enum8 datatype and only accepts values 0-11 (specific calendar types) and 255 (UseActiveLocale), as defined in the CalendarTypeEnum in the specification."),
80-
TestStep(12, "TH writes 50 to ActiveCalendarType attribute",
73+
TestStep(9, "TH reads ActiveCalendarType attribute from DUT",
74+
"Verify that the ActiveCalendarType is in `cluster_supported_calendar_types`"),
75+
TestStep(10, "For each entry in `cluster_supported_calendar_types`, TH writes that value to ActiveCalendarType, verifies that the write was successful and confirms the value via a read",
76+
"Write is successful and read value matches for every entry"),
77+
TestStep(11, "TH finds the set of CalendarTypesEnum value that do not appear in `cluster_supported_calendar_types` and saves as `cluster_not_supported_calendar_types`"),
78+
TestStep(12, "For each value in `cluster_unsupported_calendar_types`, TH writes the value to the ActiveCalendarType attributes",
79+
"DUT returns CONSTRAINT_ERROR"),
80+
TestStep(13, "TH writes 50 to ActiveCalendarType attribute",
8181
"Verify that the write request shows 0x87 (Constraint Error)."),
82-
TestStep(13, "TH writes 5 to HourFormat attribute", "Verify that the write request shows 0x87 (Constraint Error).")
82+
TestStep(14, "TH writes 5 to HourFormat attribute", "Verify that the write request shows 0x87 (Constraint Error).")
8383
]
8484
return steps
8585

8686
@async_test_body
8787
async def test_TC_LTIME_3_1(self):
88-
self.endpoint = self.get_endpoint(0)
88+
self.endpoint = self.get_endpoint(default=0)
8989
self.cluster = Clusters.TimeFormatLocalization
9090
hour_format_values = [0, 1, 255]
9191

92-
calendar_type_values = [i for i in range(0, 12)]
93-
cluster_supported_calendar_types = await self.read_single_attribute_check_success(self.cluster, self.cluster.Attributes.SupportedCalendarTypes)
94-
cluster_not_supported_calendar_types = []
95-
for ctv in calendar_type_values:
96-
if ctv not in cluster_supported_calendar_types:
97-
cluster_not_supported_calendar_types.append(ctv)
98-
calendar_type_values.append(255)
99-
100-
# Commisioning (precondition)
92+
# Commissioning (precondition)
10193
self.step(0)
10294

10395
self.step(1)
@@ -110,68 +102,73 @@ async def test_TC_LTIME_3_1(self):
110102
asserts.assert_in(hour_format, hour_format_values)
111103

112104
self.step(2)
113-
await self.write_single_attribute(self.cluster.Attributes.HourFormat(0), self.endpoint)
105+
resp = await self.write_single_attribute(self.cluster.Attributes.HourFormat(0), self.endpoint, expect_success=False)
114106

115107
self.step(3)
116-
hour_format = await self.read_single_attribute_check_success(self.cluster, self.cluster.Attributes.HourFormat)
117-
asserts.assert_equal(hour_format, 0)
108+
if resp == Status.Success:
109+
hour_format = await self.read_single_attribute_check_success(self.cluster, self.cluster.Attributes.HourFormat)
110+
asserts.assert_equal(hour_format, 0)
111+
else:
112+
self.mark_current_step_skipped()
118113

119114
self.step(4)
120-
await self.write_single_attribute(self.cluster.Attributes.HourFormat(1), self.endpoint)
115+
resp = await self.write_single_attribute(self.cluster.Attributes.HourFormat(1), self.endpoint, expect_success=False)
121116

122117
self.step(5)
123-
hour_format = await self.read_single_attribute_check_success(self.cluster, self.cluster.Attributes.HourFormat)
124-
asserts.assert_equal(hour_format, 1)
118+
if resp == Status.Success:
119+
hour_format = await self.read_single_attribute_check_success(self.cluster, self.cluster.Attributes.HourFormat)
120+
asserts.assert_equal(hour_format, 1)
121+
else:
122+
self.mark_current_step_skipped()
125123

126124
self.step(6)
127-
await self.write_single_attribute(self.cluster.Attributes.HourFormat(255), self.endpoint)
125+
resp = await self.write_single_attribute(self.cluster.Attributes.HourFormat(255), self.endpoint, expect_success=False)
128126

129127
self.step(7)
130-
hour_format = await self.read_single_attribute_check_success(self.cluster, self.cluster.Attributes.HourFormat)
131-
asserts.assert_equal(hour_format, 255)
128+
if resp == Status.Success:
129+
hour_format = await self.read_single_attribute_check_success(self.cluster, self.cluster.Attributes.HourFormat)
130+
asserts.assert_equal(hour_format, 255)
131+
else:
132+
self.mark_current_step_skipped()
132133

133134
self.step(8)
134-
activecalendartype_value = await self.read_single_attribute_check_success(self.cluster, self.cluster.Attributes.ActiveCalendarType)
135-
logging.info(f"Value for {activecalendartype_value}")
136-
asserts.assert_is_instance(activecalendartype_value, self.cluster.Enums.CalendarTypeEnum,
137-
"Activecalendartype is not type of CalendarTypeEnum")
138-
# Validate Enum8 range
139-
matter_asserts.assert_valid_uint8(activecalendartype_value, "ActiveCalendarType")
140-
# Is in range of 0-11,255
141-
asserts.assert_in(activecalendartype_value, calendar_type_values)
135+
calendar_type_values = set([i for i in range(0, 12)])
136+
calendar_type_values.add(255)
137+
cluster_supported_calendar_types = await self.read_single_attribute_check_success(self.cluster, self.cluster.Attributes.SupportedCalendarTypes)
142138

143139
self.step(9)
144-
await self.write_single_attribute(self.cluster.Attributes.ActiveCalendarType(0), self.endpoint)
145-
activecalendartype_value = await self.read_single_attribute_check_success(self.cluster, self.cluster.Attributes.ActiveCalendarType)
146-
asserts.assert_equal(activecalendartype_value, 0)
140+
active_calendar_type = await self.read_single_attribute_check_success(self.cluster, self.cluster.Attributes.ActiveCalendarType)
141+
logging.info(f"Value for {active_calendar_type}")
142+
matter_asserts.assert_valid_uint8(active_calendar_type, "ActiveCalendarType")
143+
asserts.assert_is_instance(active_calendar_type, self.cluster.Enums.CalendarTypeEnum,
144+
"ActiveCalendarType is not type of CalendarTypeEnum")
145+
asserts.assert_in(active_calendar_type, cluster_supported_calendar_types,
146+
"ActiveCalendarType is not listed in SupportedCalendarTypes")
147147

148148
self.step(10)
149149
# Verify the supported calendar types are active (can read and write).
150150
for supported in cluster_supported_calendar_types:
151151
logging.info(f"Testing for SupportedCalendarType value {supported}")
152152
await self.write_single_attribute(self.cluster.Attributes.ActiveCalendarType(supported), self.endpoint)
153-
activecalendartype_value = await self.read_single_attribute_check_success(self.cluster, self.cluster.Attributes.ActiveCalendarType)
154-
asserts.assert_equal(activecalendartype_value, supported)
153+
active_calendar_type = await self.read_single_attribute_check_success(self.cluster, self.cluster.Attributes.ActiveCalendarType)
154+
asserts.assert_equal(active_calendar_type, supported)
155+
156+
self.step(11)
157+
cluster_not_supported_calendar_types = calendar_type_values - set(cluster_supported_calendar_types)
155158

159+
self.step(12)
156160
# If is the case for not supported check they return a ConstraintError
157161
for unsupported in cluster_not_supported_calendar_types:
158162
status = await self.write_single_attribute(self.cluster.Attributes.ActiveCalendarType(
159163
unsupported), self.endpoint, expect_success=False)
160164
asserts.assert_equal(status, Status.ConstraintError,
161165
f"ConstraintError, unable to write value {unsupported} into ActiveCalendarType")
162166

163-
self.step(11)
164-
supportedcalendartype_values = await self.read_single_attribute_check_success(self.cluster, self.cluster.Attributes.SupportedCalendarTypes)
165-
# Validate Enum8
166-
logging.info(f"Supported calendar type value {supportedcalendartype_values}")
167-
for calendartype in supportedcalendartype_values:
168-
asserts.assert_in(calendartype, calendar_type_values)
169-
170-
self.step(12)
167+
self.step(13)
171168
activecalendartype_status = await self.write_single_attribute(self.cluster.Attributes.ActiveCalendarType(50), self.endpoint, expect_success=False)
172169
asserts.assert_equal(activecalendartype_status, Status.ConstraintError)
173170

174-
self.step(13)
171+
self.step(14)
175172
hourformat_status = await self.write_single_attribute(self.cluster.Attributes.HourFormat(5), self.endpoint, expect_success=False)
176173
asserts.assert_equal(hourformat_status, Status.ConstraintError)
177174

src/python_testing/test_metadata.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ not_automated:
121121
- name: TC_AVSUMTestBase.py
122122
reason:
123123
Shared code for Camera AV Settings (TC_AVSUM*), not a standalone test.
124-
- name: TC_LTIME_3_1.py
125-
reason:
126-
Flaky/failing (maybe after removing defaults)
127-
https://github.com/project-chip/connectedhomeip/issues/38860
128124

129125
# This is a list of slow tests (just arbitrarily picked around 20 seconds)
130126
# used in some script reporting for "be patient" messages as well as potentially

0 commit comments

Comments
 (0)