Skip to content

Commit 847a8d7

Browse files
committed
another fixup for 3.1
1 parent bdadfb0 commit 847a8d7

File tree

1 file changed

+24
-52
lines changed

1 file changed

+24
-52
lines changed

src/python_testing/TC_VALCC_3_1.py

+24-52
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ def steps_TC_VALCC_3_1(self) -> list[TestStep]:
4545
steps = [
4646
TestStep(1, "Commissioning, already done", is_commissioning=True),
4747
TestStep(2, "Set up a subscription to all attributes on the DUT"),
48-
TestStep(2, "Send Open command", "DUT returns SUCCESS"),
49-
TestStep(3, "Wait until TH receives and data report for TargetState set to NULL and an attribute report for CurrentState set to Open (ordering does not matter)",
48+
TestStep(3, "Send Open command", "DUT returns SUCCESS"),
49+
TestStep(4, "Wait until TH receives and data report for TargetState set to NULL and an attribute report for CurrentState set to Open (ordering does not matter)",
5050
"Expected attribute reports are received"),
51-
TestStep(4, "Read CurrentState and TargetState attribute", "CurrentState is Open, TargetState is NULL"),
52-
TestStep(5, "Send Close command", "DUT returns SUCCESS"),
53-
TestStep(3, "Wait until TH receives and data report for TargetState set to NULL and an attribute report for CurrentState set to Closed (ordering does not matter)",
51+
TestStep(5, "Read CurrentState and TargetState attribute", "CurrentState is Open, TargetState is NULL"),
52+
TestStep(6, "Send Close command", "DUT returns SUCCESS"),
53+
TestStep(7, "Wait until TH receives and data report for TargetState set to NULL and an attribute report for CurrentState set to Closed (ordering does not matter)",
5454
"Expected attribute reports are received"),
55-
TestStep(7, "Read CurrentState and TargetState attribute", "CurrentState is Closed, TargetState is NULL"),
55+
TestStep(8, "Read CurrentState and TargetState attribute", "CurrentState is Closed, TargetState is NULL"),
5656
]
5757
return steps
5858

@@ -61,73 +61,45 @@ async def test_TC_VALCC_3_1(self):
6161

6262
endpoint = self.matter_test_config.endpoint
6363

64-
self.step(1)
64+
self.step(1) # commissioning - already done
65+
66+
self.step(2)
6567
cluster = Clusters.ValveConfigurationAndControl
6668
attributes = cluster.Attributes
6769
attribute_subscription = ClusterAttributeChangeAccumulator(cluster)
6870
await attribute_subscription.start(self.default_controller, self.dut_node_id, endpoint)
6971

70-
self.step(2)
71-
try:
72-
await self.send_single_cmd(cmd=Clusters.Objects.ValveConfigurationAndControl.Commands.Open(), endpoint=endpoint)
73-
except InteractionModelError as e:
74-
asserts.assert_equal(e.status, Status.Success, "Unexpected error returned")
75-
pass
76-
7772
self.step(3)
73+
await self.send_single_cmd(cmd=Clusters.Objects.ValveConfigurationAndControl.Commands.Open(), endpoint=endpoint)
7874

75+
self.step(4)
7976
# Wait until the current state is open and the target state is Null.
8077
# Wait for the entire duration of the test because this valve may be slow. The test will time out before this does. That's fine.
8178
timeout = self.matter_test_config.timeout if self.matter_test_config.timeout is not None else self.default_timeout
8279
expected_final_state = [AttributeValue(endpoint_id=endpoint, attribute=attributes.TargetState, value=NullValue), AttributeValue(
8380
endpoint_id=endpoint, attribute=attributes.CurrentState, value=cluster.Enums.ValveStateEnum.kOpen)]
8481
attribute_subscription.await_all_final_values_reported(expected_final_values=expected_final_state, timeout_sec=timeout)
8582

86-
# Read target state first in case the current state goes to open between these calls.
87-
# The test re-reads target state after CurrentState goes to open.
88-
target_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetState)
89-
current_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentState)
90-
91-
while current_state_dut is cluster.Enums.ValveStateEnum.kTransitioning:
92-
asserts.assert_equal(target_state_dut, cluster.Enums.ValveStateEnum.kOpen, "TargetState is incorrect")
93-
time.sleep(1)
94-
95-
target_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetState)
96-
current_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentState)
97-
asserts.assert_true(current_state_dut is not NullValue, "CurrentState is null")
98-
asserts.assert_true(target_state_dut is not NullValue, "TargetState is null")
99-
100-
self.step(4)
101-
current_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentState)
102-
asserts.assert_equal(current_state_dut, cluster.Enums.ValveStateEnum.kOpen, "CurrentState is incorrect")
103-
target_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetState)
104-
asserts.assert_true(target_state_dut is NullValue, "TargetState is not null")
105-
10683
self.step(5)
107-
try:
108-
await self.send_single_cmd(cmd=Clusters.Objects.ValveConfigurationAndControl.Commands.Close(), endpoint=endpoint)
109-
except InteractionModelError as e:
110-
asserts.assert_equal(e.status, Status.Success, "Unexpected error returned")
111-
pass
112-
113-
self.step(6)
11484
target_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetState)
11585
current_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentState)
86+
asserts.assert_equal(current_state_dut, cluster.Enums.ValveStateEnum.kOpen, "CurrentState is not open")
87+
asserts.assert_equal(target_state_dut, NullValue, "TargetState is not null")
11688

117-
while current_state_dut is cluster.Enums.ValveStateEnum.kTransitioning:
118-
asserts.assert_equal(target_state_dut, cluster.Enums.ValveStateEnum.kClosed, "TargetState is incorrect")
119-
time.sleep(1)
120-
121-
target_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetState)
122-
current_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentState)
123-
asserts.assert_true(current_state_dut is not NullValue, "CurrentState is null")
124-
asserts.assert_true(target_state_dut is not NullValue, "TargetState is null")
89+
self.step(6)
90+
attribute_subscription.reset()
91+
await self.send_single_cmd(cmd=Clusters.Objects.ValveConfigurationAndControl.Commands.Close(), endpoint=endpoint)
12592

12693
self.step(7)
127-
current_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentState)
128-
asserts.assert_equal(current_state_dut, cluster.Enums.ValveStateEnum.kClosed, "CurrentState is incorrect")
94+
expected_final_state = [AttributeValue(endpoint_id=endpoint, attribute=attributes.TargetState, value=NullValue), AttributeValue(
95+
endpoint_id=endpoint, attribute=attributes.CurrentState, value=cluster.Enums.ValveStateEnum.kClosed)]
96+
attribute_subscription.await_all_final_values_reported(expected_final_values=expected_final_state, timeout_sec=timeout)
97+
98+
self.step(8)
12999
target_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetState)
130-
asserts.assert_true(target_state_dut is NullValue, "TargetState is not null")
100+
current_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentState)
101+
asserts.assert_equal(current_state_dut, cluster.Enums.ValveStateEnum.kClosed, "CurrentState is not closed")
102+
asserts.assert_equal(target_state_dut, NullValue, "TargetState is not null")
131103

132104

133105
if __name__ == "__main__":

0 commit comments

Comments
 (0)