Skip to content

Commit 8dc2e89

Browse files
rbultmanaustina-csa
authored andcommitted
[OVENOPSTATE] Add OvenOpState 2.6 test case from base (second try) (project-chip#34783)
* Add OvenOpState 2.6 * Added steps to me TP easier to write * Reduce sleep, fix checks * Changed test
1 parent eb4bc06 commit 8dc2e89

File tree

2 files changed

+108
-27
lines changed

2 files changed

+108
-27
lines changed
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments
19+
# for details about the block below.
20+
#
21+
# === BEGIN CI TEST ARGUMENTS ===
22+
# test-runner-runs: run1
23+
# test-runner-run/run1/app: ${ALL_CLUSTERS_APP}
24+
# test-runner-run/run1/factoryreset: True
25+
# test-runner-run/run1/quiet: True
26+
# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json
27+
# test-runner-run/run1/script-args: --endpoint 1 --int-arg PIXIT.WAITTIME.REBOOT:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
28+
# === END CI TEST ARGUMENTS ===
29+
30+
31+
import chip.clusters as Clusters
32+
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
33+
from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo
34+
35+
36+
class TC_OVENOPSTATE_2_6(MatterBaseTest, TC_OPSTATE_BASE):
37+
def __init__(self, *args):
38+
super().__init__(*args)
39+
40+
test_info = TestInfo(
41+
pics_code="OVENOPSTATE",
42+
cluster=Clusters.OvenCavityOperationalState
43+
)
44+
45+
super().setup_base(test_info=test_info)
46+
47+
def steps_TC_OVENOPSTATE_2_6(self) -> list[TestStep]:
48+
return self.steps_TC_OPSTATE_BASE_2_6()
49+
50+
def pics_TC_OVENOPSTATE_2_6(self) -> list[str]:
51+
return ["OVENOPSTATE.S", "OVENOPSTATE.S.A0002"]
52+
53+
@async_test_body
54+
async def test_TC_OVENOPSTATE_2_6(self):
55+
# endpoint = self.matter_test_config.endpoint
56+
57+
# await self.TEST_TC_OPSTATE_BASE_2_6(endpoint=endpoint)
58+
await self.TEST_TC_OPSTATE_BASE_2_6(endpoint=1)
59+
60+
61+
if __name__ == "__main__":
62+
default_matter_test_main()

src/python_testing/TC_OpstateCommon.py

+46-27
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,8 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1):
11021102
f"Completion event error code mismatched from expectation on endpoint {endpoint}.")
11031103

11041104
if event_data.totalOperationalTime is not NullValue:
1105-
asserts.assert_less_equal(initial_countdown_time, event_data.totalOperationalTime,
1105+
time_diff = abs(initial_countdown_time - event_data.totalOperationalTime)
1106+
asserts.assert_less_equal(time_diff, 1,
11061107
f"The total operation time shall be at least {initial_countdown_time:.1f}")
11071108

11081109
asserts.assert_equal(0, event_data.pausedTime,
@@ -1231,15 +1232,20 @@ def steps_TC_OPSTATE_BASE_2_6(self) -> list[TestStep]:
12311232
TestStep(2, "Subscribe to CountdownTime attribute"),
12321233
TestStep(3, "Manually put the DUT into a state where it will use the CountdownTime attribute, "
12331234
"the initial value of the CountdownTime is greater than 30, "
1234-
"and it will begin counting down the CountdownTime attribute."),
1235-
TestStep(4, "Over a period of 30 seconds, TH counts all report transactions with an attribute "
1235+
"and it will begin counting down the CountdownTime attribute. "
1236+
"Test harness reads the CountdownTime attribute."),
1237+
TestStep(4, "Test harness reads the CountdownTime attribute."),
1238+
TestStep(5, "Over a period of 30 seconds, TH counts all report transactions with an attribute "
12361239
"report for the CountdownTime attribute in numberOfReportsReceived"),
1237-
TestStep(5, "Until the current operation finishes, TH counts all report transactions with "
1240+
TestStep(6, "Test harness reads the CountdownTime attribute."),
1241+
TestStep(7, "Until the current operation finishes, TH counts all report transactions with "
12381242
"an attribute report for the CountdownTime attribute in numberOfReportsReceived and saves up to 5 such reports."),
1239-
TestStep(6, "Manually put the DUT into a state where it will use the CountdownTime attribute, "
1240-
"the initial value of the CountdownTime is greater than 30, and it will begin counting down the CountdownTime attribute."),
1241-
TestStep(7, "TH reads from the DUT the OperationalState attribute"),
1242-
TestStep(8, "Manually put the device in the Paused(0x02) operational state")
1243+
TestStep(8, "Manually put the DUT into a state where it will use the CountdownTime attribute, "
1244+
"the initial value of the CountdownTime is greater than 30, and it will begin counting down the CountdownTime attribute."
1245+
"Test harness reads the CountdownTime attribute."),
1246+
TestStep(9, "TH reads from the DUT the OperationalState attribute"),
1247+
TestStep(10, "Test harness reads the CountdownTime attribute."),
1248+
TestStep(11, "Manually put the device in the Paused(0x02) operational state")
12431249
]
12441250
return steps
12451251

@@ -1267,26 +1273,35 @@ async def TEST_TC_OPSTATE_BASE_2_6(self, endpoint=1):
12671273
await self.read_and_expect_value(endpoint=endpoint,
12681274
attribute=attributes.OperationalState,
12691275
expected_value=cluster.Enums.OperationalStateEnum.kRunning)
1270-
count = sub_handler.attribute_report_counts[attributes.CountdownTime]
1271-
asserts.assert_greater(count, 0, "Did not receive any reports for CountdownTime")
1276+
countdownTime = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CountdownTime)
1277+
if countdownTime is not NullValue:
1278+
count = sub_handler.attribute_report_counts[attributes.CountdownTime]
1279+
asserts.assert_greater(count, 0, "Did not receive any reports for CountdownTime")
12721280
else:
12731281
self.skip_step(3)
12741282

12751283
sub_handler.reset()
12761284
self.step(4)
1277-
logging.info('Test will now collect data for 30 seconds')
1278-
time.sleep(30)
1285+
countdownTime = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CountdownTime)
1286+
if countdownTime is not NullValue:
1287+
self.step(5)
1288+
logging.info('Test will now collect data for 10 seconds')
1289+
time.sleep(10)
12791290

1280-
count = sub_handler.attribute_report_counts[attributes.CountdownTime]
1281-
sub_handler.reset()
1282-
asserts.assert_less_equal(count, 5, "Received more than 5 reports for CountdownTime")
1283-
asserts.assert_greater_equal(count, 0, "Did not receive any reports for CountdownTime")
1291+
count = sub_handler.attribute_report_counts[attributes.CountdownTime]
1292+
sub_handler.reset()
1293+
asserts.assert_less_equal(count, 5, "Received more than 5 reports for CountdownTime")
1294+
asserts.assert_greater_equal(count, 0, "Did not receive any reports for CountdownTime")
1295+
else:
1296+
self.skip_step(5)
12841297

1298+
self.step(6)
1299+
countdownTime = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CountdownTime)
12851300
attr_value = await self.read_expect_success(
12861301
endpoint=endpoint,
12871302
attribute=attributes.OperationalState)
1288-
if attr_value == cluster.Enums.OperationalStateEnum.kRunning:
1289-
self.step(5)
1303+
if attr_value == cluster.Enums.OperationalStateEnum.kRunning and countdownTime is not NullValue:
1304+
self.step(7)
12901305
wait_count = 0
12911306
while (attr_value != cluster.Enums.OperationalStateEnum.kStopped) and (wait_count < 20):
12921307
time.sleep(1)
@@ -1298,36 +1313,40 @@ async def TEST_TC_OPSTATE_BASE_2_6(self, endpoint=1):
12981313
asserts.assert_less_equal(count, 5, "Received more than 5 reports for CountdownTime")
12991314
asserts.assert_greater(count, 0, "Did not receive any reports for CountdownTime")
13001315
else:
1301-
self.skip_step(5)
1316+
self.skip_step(7)
13021317

13031318
sub_handler.reset()
1304-
self.step(6)
13051319
if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ST_RUNNING")):
1320+
self.step(8)
13061321
self.send_manual_or_pipe_command(name="OperationalStateChange",
13071322
device=self.device,
13081323
operation="Start")
13091324
time.sleep(1)
13101325
await self.read_and_expect_value(endpoint=endpoint,
13111326
attribute=attributes.OperationalState,
13121327
expected_value=cluster.Enums.OperationalStateEnum.kRunning)
1313-
count = sub_handler.attribute_report_counts[attributes.CountdownTime]
1314-
asserts.assert_greater(count, 0, "Did not receive any reports for CountdownTime")
1328+
countdownTime = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CountdownTime)
1329+
if countdownTime is not NullValue:
1330+
count = sub_handler.attribute_report_counts[attributes.CountdownTime]
1331+
asserts.assert_greater(count, 0, "Did not receive any reports for CountdownTime")
13151332
else:
1316-
self.skip_step(6)
1333+
self.skip_step(8)
13171334

1318-
self.step(7)
1335+
self.step(9)
13191336
await self.read_and_expect_value(endpoint=endpoint,
13201337
attribute=attributes.OperationalState,
13211338
expected_value=cluster.Enums.OperationalStateEnum.kRunning)
13221339

13231340
sub_handler.reset()
1324-
self.step(8)
1325-
if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ST_PAUSED")):
1341+
self.step(10)
1342+
countdownTime = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CountdownTime)
1343+
if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ST_PAUSED")) and countdownTime is not NullValue:
1344+
self.step(11)
13261345
self.send_manual_or_pipe_command(name="OperationalStateChange",
13271346
device=self.device,
13281347
operation="Pause")
13291348
time.sleep(1)
13301349
count = sub_handler.attribute_report_counts[attributes.CountdownTime]
13311350
asserts.assert_greater(count, 0, "Did not receive any reports for CountdownTime")
13321351
else:
1333-
self.skip_step(8)
1352+
self.skip_step(11)

0 commit comments

Comments
 (0)