Skip to content

Commit 4582785

Browse files
mhazleypull[bot]
authored andcommitted
Move TC_FAN_3_1 and TC_FAN_3_2 to python and update following test plan change (#31515)
* Moved TC_FAN_3_1 and TC_FAN_3_2 over to python following updates to test plan in PR3835 * Regenerated code following moving two test scripts to Python * Adding PICS function so TH can support these tests better * Modifying the pics_ function to better vibe with Cecille's plan
1 parent 1e2fad6 commit 4582785

File tree

7 files changed

+244
-1021
lines changed

7 files changed

+244
-1021
lines changed

.github/workflows/tests.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,8 @@ jobs:
481481
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-lit-icd-ipv6only-no-ble-no-wifi-tsan-clang-test/lit-icd-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_ICDM_2_1.py" --script-args "--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:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
482482
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_DA_1_5.py" --script-args "--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:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
483483
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_IDM_1_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
484+
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_FAN_3_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
485+
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_FAN_3_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
484486
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_FAN_3_3.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
485487
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_FAN_3_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
486488
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_FAN_3_5.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'

src/app/tests/suites/certification/Test_TC_FAN_3_1.yaml

-148
This file was deleted.

src/app/tests/suites/certification/Test_TC_FAN_3_2.yaml

-74
This file was deleted.

src/app/tests/suites/ciTests.json

-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@
6464
"Test_TC_FAN_2_2",
6565
"Test_TC_FAN_2_3",
6666
"Test_TC_FAN_2_4",
67-
"Test_TC_FAN_3_1",
68-
"Test_TC_FAN_3_2",
6967
"Test_TC_FAN_3_6"
7068
],
7169
"GeneralCommissioning": ["Test_TC_CGEN_1_1", "Test_TC_CGEN_2_1"],

src/python_testing/TC_FAN_3_1.py

+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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 logging
19+
import time
20+
21+
import chip.clusters as Clusters
22+
from chip.interaction_model import Status
23+
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main
24+
from mobly import asserts
25+
26+
logger = logging.getLogger(__name__)
27+
28+
29+
class TC_FAN_3_1(MatterBaseTest):
30+
31+
async def read_fc_attribute_expect_success(self, endpoint, attribute):
32+
cluster = Clusters.Objects.FanControl
33+
return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute)
34+
35+
async def read_fan_mode(self, endpoint):
36+
return await self.read_fc_attribute_expect_success(endpoint, Clusters.FanControl.Attributes.FanMode)
37+
38+
async def read_percent_setting(self, endpoint):
39+
return await self.read_fc_attribute_expect_success(endpoint, Clusters.FanControl.Attributes.PercentSetting)
40+
41+
async def read_percent_current(self, endpoint):
42+
return await self.read_fc_attribute_expect_success(endpoint, Clusters.FanControl.Attributes.PercentCurrent)
43+
44+
async def write_fan_mode(self, endpoint, fan_mode) -> Status:
45+
result = await self.default_controller.WriteAttribute(self.dut_node_id, [(endpoint, Clusters.FanControl.Attributes.FanMode(fan_mode))])
46+
return result[0].Status
47+
48+
async def write_percent_setting(self, endpoint, percent_setting) -> Status:
49+
result = await self.default_controller.WriteAttribute(self.dut_node_id, [(endpoint, Clusters.FanControl.Attributes.PercentSetting(percent_setting))])
50+
return result[0].Status
51+
52+
def pics_TC_FAN_3_1(self) -> list[str]:
53+
return ["FAN.S"]
54+
55+
@async_test_body
56+
async def test_TC_FAN_3_1(self):
57+
endpoint = self.user_params.get("endpoint", 1)
58+
59+
self.print_step(1, "Commissioning, already done")
60+
61+
self.print_step("2a", "Read from the DUT the FanMode attribute and store")
62+
existing_fan_mode = await self.read_fan_mode(endpoint=endpoint)
63+
64+
self.print_step("2b", "Write High to FanMode")
65+
status = await self.write_fan_mode(endpoint=endpoint, fan_mode=Clusters.FanControl.Enums.FanModeEnum.kHigh)
66+
status_ok = (status == Status.Success) or (status == Status.InvalidInState)
67+
asserts.assert_true(status_ok, "FanMode write did not return a value of Success or InvalidInState")
68+
69+
self.print_step("2c", "After a few seconds, read from the DUT the FanMode attribute")
70+
time.sleep(3)
71+
72+
new_fan_mode = await self.read_fan_mode(endpoint=endpoint)
73+
74+
if status == Status.Success:
75+
asserts.assert_equal(new_fan_mode, Clusters.FanControl.Enums.FanModeEnum.kHigh, "FanMode is not High")
76+
else:
77+
asserts.assert_equal(new_fan_mode, existing_fan_mode, "FanMode is not unchanged")
78+
79+
self.print_step("3a", "Read from the DUT the PercentSetting attribute and store")
80+
existing_percent_setting = await self.read_percent_setting(endpoint=endpoint)
81+
82+
self.print_step("3b", "Write Off to Fan Mode")
83+
status = await self.write_fan_mode(endpoint=endpoint, fan_mode=Clusters.FanControl.Enums.FanModeEnum.kOff)
84+
status_ok = (status == Status.Success) or (status == Status.InvalidInState)
85+
asserts.assert_true(status_ok, "FanMode write did not return a value of Success or InvalidInState")
86+
87+
self.print_step("3c", "After a few seconds, read from the DUT the PercentSetting attribute")
88+
time.sleep(3)
89+
90+
new_percent_setting = await self.read_percent_setting(endpoint=endpoint)
91+
92+
if status == Status.Success:
93+
asserts.assert_equal(new_percent_setting, Clusters.FanControl.Enums.FanModeEnum.kOff, "PercentSetting is not Off")
94+
else:
95+
asserts.assert_equal(new_percent_setting, existing_percent_setting, "PercentSetting is not unchanged")
96+
97+
self.print_step("3d", "Read from the DUT the PercentCurrent attribute")
98+
percent_current = await self.read_percent_current(endpoint=endpoint)
99+
100+
if status == Status.Success:
101+
asserts.assert_equal(percent_current, 0, "PercentCurrent is not 0")
102+
else:
103+
asserts.assert_equal(percent_current, existing_percent_setting, "PercentCurrent is not unchanged")
104+
105+
self.print_step("4a", "Read from the DUT the PercentSetting attribute and store")
106+
existing_percent_setting = await self.read_percent_setting(endpoint=endpoint)
107+
108+
self.print_step("4b", "Write PercentSetting to 30")
109+
status = await self.write_percent_setting(endpoint=endpoint, percent_setting=30)
110+
status_ok = (status == Status.Success) or (status == Status.InvalidInState)
111+
asserts.assert_true(status_ok, "PercentSetting write did not return a value of Success or InvalidInState")
112+
113+
self.print_step("4c", "After a few seconds, read from the DUT the PercentSetting attribute")
114+
time.sleep(3)
115+
116+
new_percent_setting = await self.read_percent_setting(endpoint=endpoint)
117+
118+
if status == Status.Success:
119+
asserts.assert_equal(new_percent_setting, 30, "PercentSetting is not 30")
120+
else:
121+
asserts.assert_equal(new_percent_setting, existing_percent_setting, "PercentSetting is not unchanged")
122+
123+
self.print_step("4d", "Read from the DUT the PercentCurrent attribute")
124+
percent_current = await self.read_percent_current(endpoint=endpoint)
125+
126+
if status == Status.Success:
127+
asserts.assert_equal(percent_current, 30, "PercentCurrent is not 30")
128+
else:
129+
asserts.assert_equal(percent_current, existing_percent_setting, "PercentCurrent is not unchanged")
130+
131+
self.print_step("5a", "Read from the DUT the FanMode attribute and store")
132+
existing_fan_mode = await self.read_fan_mode(endpoint=endpoint)
133+
134+
self.print_step("5b", "Write PercentSetting to 0")
135+
status = await self.write_percent_setting(endpoint=endpoint, percent_setting=0)
136+
status_ok = (status == Status.Success) or (status == Status.InvalidInState)
137+
asserts.assert_true(status_ok, "PercentSetting write did not return a value of Success or InvalidInState")
138+
139+
self.print_step("5c", "After a few seconds, read from the DUT the FanMode attribute")
140+
time.sleep(3)
141+
142+
new_fan_mode = await self.read_fan_mode(endpoint=endpoint)
143+
144+
if status == Status.Success:
145+
asserts.assert_equal(new_fan_mode, Clusters.FanControl.Enums.FanModeEnum.kOff, "FanMode is not Off")
146+
else:
147+
asserts.assert_equal(new_fan_mode, existing_fan_mode, "FanMode is not unchanged")
148+
149+
150+
if __name__ == "__main__":
151+
default_matter_test_main()

0 commit comments

Comments
 (0)