Skip to content

Commit fa83b47

Browse files
committed
TC-VALCC-3.1: Allow immediate open of valve
If the valve can be opened before the command is complete or before the next read is done, the test will fail because it expects the transitioning phase to happen. In the spec: When the movement is complete, the device SHALL set the CurrentState attribute to the Open value. ^ this can happen before the end of the command.
1 parent f509f67 commit fa83b47

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

src/python_testing/TC_VALCC_3_1.py

+29-25
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ def steps_TC_VALCC_3_1(self) -> list[TestStep]:
4545
steps = [
4646
TestStep(1, "Commissioning, already done", is_commissioning=True),
4747
TestStep(2, "Send Open command"),
48-
TestStep(3, "Read TargetState attribute"),
49-
TestStep(4, "Read CurrentState attribute"),
48+
TestStep(3, "Read CurrentState and TargetState attribute until CurrentState is Open",
49+
"Target state is Open while CurrentState is Transitioning"),
50+
TestStep(4, "Read CurrentState and TargetState attribute", "CurrentState is Open, TargetState is NULL"),
5051
TestStep(5, "Send Close command"),
51-
TestStep(6, "Read TargetState attribute"),
52-
TestStep(7, "Read CurrentState attribute"),
52+
TestStep(6, "Read CurrentState and TargetState attribute until CurrentState is Open",
53+
"Target state is Closed while CurrentState is Transitioning"),
54+
TestStep(7, "Read CurrentState and TargetState attribute", "CurrentState is Closed, TargetState is NULL"),
5355
]
5456
return steps
5557

@@ -65,7 +67,8 @@ async def test_TC_VALCC_3_1(self):
6567
endpoint = self.user_params.get("endpoint", 1)
6668

6769
self.step(1)
68-
attributes = Clusters.ValveConfigurationAndControl.Attributes
70+
cluster = Clusters.ValveConfigurationAndControl
71+
attributes = cluster.Attributes
6972

7073
self.step(2)
7174
try:
@@ -75,24 +78,26 @@ async def test_TC_VALCC_3_1(self):
7578
pass
7679

7780
self.step(3)
78-
target_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetState)
79-
80-
asserts.assert_true(target_state_dut is not NullValue, "TargetState is null")
81-
asserts.assert_equal(target_state_dut, Clusters.Objects.ValveConfigurationAndControl.Enums.ValveStateEnum.kOpen,
82-
"TargetState is not the expected value")
8381

84-
self.step(4)
82+
# Read target state first in case the current state goes to open between these calls.
83+
# The test re-reads target state after CurrentState goes to open.
84+
target_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetState)
8585
current_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentState)
86-
asserts.assert_true(current_state_dut is not NullValue, "CurrentState is null")
8786

88-
while current_state_dut is Clusters.Objects.ValveConfigurationAndControl.Enums.ValveStateEnum.kTransitioning:
87+
while current_state_dut is cluster.Enums.ValveStateEnum.kTransitioning:
88+
asserts.assert_equal(target_state_dut, cluster.Enums.ValveStateEnum.kOpen, "TargetState is incorrect")
8989
time.sleep(1)
9090

91+
target_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetState)
9192
current_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentState)
9293
asserts.assert_true(current_state_dut is not NullValue, "CurrentState is null")
94+
asserts.assert_true(target_state_dut is not NullValue, "TargetState is null")
9395

94-
asserts.assert_equal(current_state_dut, Clusters.Objects.ValveConfigurationAndControl.Enums.ValveStateEnum.kOpen,
95-
"CurrentState is not the expected value")
96+
self.step(4)
97+
current_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentState)
98+
asserts.assert_equal(current_state_dut, cluster.Enums.ValveStateEnum.kOpen, "CurrentState is incorrect")
99+
target_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetState)
100+
asserts.assert_true(target_state_dut is NullValue, "TargetState is not null")
96101

97102
self.step(5)
98103
try:
@@ -103,23 +108,22 @@ async def test_TC_VALCC_3_1(self):
103108

104109
self.step(6)
105110
target_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetState)
106-
107-
asserts.assert_true(target_state_dut is not NullValue, "TargetState is null")
108-
asserts.assert_equal(target_state_dut, Clusters.Objects.ValveConfigurationAndControl.Enums.ValveStateEnum.kClosed,
109-
"TargetState is not the expected value")
110-
111-
self.step(7)
112111
current_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentState)
113-
asserts.assert_true(current_state_dut is not NullValue, "CurrentState is null")
114112

115-
while current_state_dut is Clusters.Objects.ValveConfigurationAndControl.Enums.ValveStateEnum.kTransitioning:
113+
while current_state_dut is cluster.Enums.ValveStateEnum.kTransitioning:
114+
asserts.assert_equal(target_state_dut, cluster.Enums.ValveStateEnum.kClosed, "TargetState is incorrect")
116115
time.sleep(1)
117116

117+
target_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetState)
118118
current_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentState)
119119
asserts.assert_true(current_state_dut is not NullValue, "CurrentState is null")
120+
asserts.assert_true(target_state_dut is not NullValue, "TargetState is null")
120121

121-
asserts.assert_equal(current_state_dut, Clusters.Objects.ValveConfigurationAndControl.Enums.ValveStateEnum.kClosed,
122-
"CurrentState is not the expected value")
122+
self.step(7)
123+
current_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentState)
124+
asserts.assert_equal(current_state_dut, cluster.Enums.ValveStateEnum.kClosed, "CurrentState is incorrect")
125+
target_state_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetState)
126+
asserts.assert_true(target_state_dut is NullValue, "TargetState is not null")
123127

124128

125129
if __name__ == "__main__":

0 commit comments

Comments
 (0)