Skip to content

Commit d49652a

Browse files
[AVSUM Test Scripts] Update AVSUM test cases as per issue 5438 (project-chip#40762)
* Update AVSUM test cases as per issue 5438 * Restyled by autopep8 * Restyled by isort * Address Gemini comments * Align with changed attribute name * Restyled by autopep8 --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent b0efaeb commit d49652a

6 files changed

Lines changed: 235 additions & 58 deletions

File tree

src/python_testing/TC_AVSUMTestBase.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,22 @@ async def send_mptz_relative_move_command(self, endpoint, panDelta, tiltDelta, z
211211
except InteractionModelError as e:
212212
asserts.assert_equal(e.status, expected_status, "Unexpected error returned")
213213

214+
async def dptzstreamentryvalid(self, endpoint, videoStreamID, viewport):
215+
dptz_streams_dut = await self.read_avsum_attribute_expect_success(endpoint, Clusters.Objects.CameraAvSettingsUserLevelManagement.attributes.DPTZStreams)
216+
match_found = False
217+
if dptz_streams_dut is not None:
218+
for streams in dptz_streams_dut:
219+
if streams.videoStreamID == videoStreamID:
220+
# verify the viewport matches
221+
if (streams.viewport == viewport):
222+
match_found = True
223+
break
224+
225+
else:
226+
asserts.assert_fail("DPTZStreams is empty, even though a stream has been allocated")
227+
228+
return match_found
229+
214230
async def video_stream_allocate_command(self, endpoint, expected_status: Status = Status.Success):
215231
cluster = Clusters.Objects.CameraAvStreamManagement
216232
attrs = cluster.Attributes

src/python_testing/TC_AVSUM_2_2.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,28 @@ def steps_TC_AVSUM_2_2(self) -> list[TestStep]:
5959
TestStep(1, "Commissioning, already done", is_commissioning=True),
6060
TestStep(2, "Read and verify MPTZPosition attribute."),
6161
TestStep(3, "Send an MPTZSetPosition command with no fields. Verify failure response"),
62-
TestStep(4, "If Pan is supported, read and verify the PanMin attribute. If not skip to step 8"),
62+
TestStep(4, "If Pan is supported, read and verify the PanMin attribute. If not skip to step 14"),
6363
TestStep(5, "Read and verify the PanMax attribute."),
6464
TestStep(6, "Create a valid value for a Pan"),
6565
TestStep(7, "Set the new Pan value via the MPTZSetPosition command. Verify success response."),
66-
TestStep(8, "Read MPTZPosition. Verify the Pan value is that set in Step 7."),
66+
TestStep(8, "Read MPTZPosition. Verify the Pan value is that set in Step 7. Verify the Tilt and Zoom are unchanged."),
6767
TestStep(9, "If PIXIT.CANBEMADEBUSY is set, place the DUT into a state where it cannot accept a command. Else jump to step 11."),
6868
TestStep(10, "Send an MPTZSetPositionCommand with the previously set Pan value. Verify failure response."),
6969
TestStep(11, "Create an invalid value for a Pan."),
7070
TestStep(12, "Set the invalid value via the MPTZSetPosition command. Verify failure response."),
7171
TestStep(13, "Read MPTZPosition. Verify the Pan value is that set in Step 7."),
72-
TestStep(14, "If Tilt is supported, read and verify the TiltMin and TiltMax attributes. If not skip to step 13"),
72+
TestStep(14, "If Tilt is supported, read and verify the TiltMin and TiltMax attributes. If not skip to step 22"),
7373
TestStep(15, "Read and verify the TiltMax attribute."),
7474
TestStep(16, "Create a valid value for a Tilt different from the initial value."),
7575
TestStep(17, "Set the new Tilt value via the MPTZSetPosition command. Verify success response."),
76-
TestStep(18, "Read MPTZPosition. Verify the Tilt value is that set in Step 16."),
76+
TestStep(18, "Read MPTZPosition. Verify the Tilt value is that set in Step 17. Verify that Pan and Zoom are unchanged"),
7777
TestStep(19, "Create an invalid value for a Tilt."),
7878
TestStep(20, "Set the invalid value via the MPTZSetPosition command. Verify failure response."),
79-
TestStep(21, "Read MPTZPosition. Verify the Tilt value is that set in Step 16."),
79+
TestStep(21, "Read MPTZPosition. Verify the Tilt value is that set in Step 17."),
8080
TestStep(22, "If Zoom is supported, read and verify the ZoomMax attribute."),
8181
TestStep(23, "Create a valid value for Zoom."),
8282
TestStep(24, "Set the new Zoom value via the MPTZSetPosition command. Verify success response."),
83-
TestStep(25, "Read MPTZPosition. Verify the Zoom value is that set in Step 24."),
83+
TestStep(25, "Read MPTZPosition. Verify the Zoom value is that set in Step 24. Verify Pan and Tilt are unchanged"),
8484
TestStep(26, "Create an invalid value for a Zoom."),
8585
TestStep(27, "Set the invalid value via the MPTZSetPosition command. Verify failure response."),
8686
TestStep(28, "Read MPTZPosition. Verify the Zoom value is that set in Step 24."),
@@ -117,9 +117,9 @@ async def test_TC_AVSUM_2_2(self):
117117
asserts.assert_in(attributes.MPTZPosition.attribute_id, attribute_list,
118118
"MPTZPosition attribute is mandatory if the command is supported.")
119119
mptzposition_dut = await self.read_avsum_attribute_expect_success(endpoint, attributes.MPTZPosition)
120-
initialPan = mptzposition_dut.pan
121-
initialTilt = mptzposition_dut.tilt
122-
initialZoom = mptzposition_dut.zoom
120+
currentPan = mptzposition_dut.pan
121+
currentTilt = mptzposition_dut.tilt
122+
currentZoom = mptzposition_dut.zoom
123123

124124
self.step(3)
125125
await self.send_null_mptz_set_position_command(endpoint, expected_status=Status.InvalidCommand)
@@ -143,7 +143,7 @@ async def test_TC_AVSUM_2_2(self):
143143
# Create new Value for Pan
144144
while True:
145145
newPan = random.randint(pan_min_dut, pan_max_dut)
146-
if newPan != initialPan:
146+
if newPan != currentPan:
147147
break
148148

149149
self.step(7)
@@ -154,6 +154,9 @@ async def test_TC_AVSUM_2_2(self):
154154
# Read the attribute back and make sure it was set
155155
newpan_mptzposition_dut = await self.read_avsum_attribute_expect_success(endpoint, attributes.MPTZPosition)
156156
asserts.assert_equal(newpan_mptzposition_dut.pan, newPan, "Received Pan does not match set Pan")
157+
asserts.assert_equal(newpan_mptzposition_dut.tilt, currentTilt, "Tilt unexpectedly changed when only changing Pan")
158+
asserts.assert_equal(newpan_mptzposition_dut.zoom, currentZoom, "Zoom unexpectedly changed when only changing Pan")
159+
currentPan = newPan
157160

158161
self.step(9)
159162
# PIXIT check
@@ -210,7 +213,7 @@ async def test_TC_AVSUM_2_2(self):
210213
# Create new Value for Tilt
211214
while True:
212215
newTilt = random.randint(tilt_min_dut, tilt_max_dut)
213-
if newTilt != initialTilt:
216+
if newTilt != currentTilt:
214217
break
215218

216219
self.step(17)
@@ -221,6 +224,9 @@ async def test_TC_AVSUM_2_2(self):
221224
# Read the attribute back and make sure it was set
222225
newtilt_mptzposition_dut = await self.read_avsum_attribute_expect_success(endpoint, attributes.MPTZPosition)
223226
asserts.assert_equal(newtilt_mptzposition_dut.tilt, newTilt, "Received Tilt does not match set Tilt")
227+
asserts.assert_equal(newtilt_mptzposition_dut.pan, currentPan, "Pan unexpectedly changed when only changing Tilt")
228+
asserts.assert_equal(newtilt_mptzposition_dut.zoom, currentZoom, "Zoom unexpectedly changed when only changing Tilt")
229+
currentTilt = newTilt
224230

225231
self.step(19)
226232
# Create an out of range value for Tilt, verify failure
@@ -255,7 +261,7 @@ async def test_TC_AVSUM_2_2(self):
255261
# Create new Value for Zoom
256262
while True:
257263
newZoom = random.randint(2, zoom_max_dut)
258-
if newZoom != initialZoom:
264+
if newZoom != currentZoom:
259265
break
260266

261267
self.step(24)
@@ -278,6 +284,8 @@ async def test_TC_AVSUM_2_2(self):
278284
# Verify no change in the Zoom value
279285
newzoom_mptzposition_dut = await self.read_avsum_attribute_expect_success(endpoint, attributes.MPTZPosition)
280286
asserts.assert_equal(newzoom_mptzposition_dut.zoom, newZoom, "Received Zoom does not match set Zoom")
287+
asserts.assert_equal(newzoom_mptzposition_dut.pan, currentPan, "Pan unexpectedly changed when only changing Zoom")
288+
asserts.assert_equal(newzoom_mptzposition_dut.tilt, currentTilt, "Tilt unexpectedly changed when only changing Zoom")
281289
else:
282290
self.skip_step(22)
283291
self.skip_step(23)

src/python_testing/TC_AVSUM_2_3.py

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,30 +56,30 @@ def steps_TC_AVSUM_2_3(self) -> list[TestStep]:
5656
TestStep(1, "Commissioning, already done", is_commissioning=True),
5757
TestStep(2, "Read and verify MPTZPosition attribute."),
5858
TestStep(3, "Send an MPTZRelativeMove command with no fields. Verify failure response"),
59-
TestStep(4, "If Pan is supported, read and verify the PanMin attribute. If not skip to step 14"),
59+
TestStep(4, "If Pan is supported, read and verify the PanMin attribute. If not skip to step 12"),
6060
TestStep(5, "Read and verify the PanMax attribute."),
6161
TestStep(6, "Create a valid value for a Pan, calculate the relative distance from the current Pan."),
6262
TestStep(7, "Set via MPTZRelativeMove command the relative Pan. Verify success response."),
63-
TestStep(8, "Read MPTZPosition. Verify the Pan value is that set in Step 6."),
63+
TestStep(8, "Read MPTZPosition. Verify the Pan value is that set in Step 7. Verify the Tilt and Zoom are unchanged."),
6464
TestStep(9, "Create an invalid value for a relative Pan that would exceed PanMax."),
6565
TestStep(10, "Set via MPTZSetRelativeMove command the invalid relative Pan. Verify success response."),
6666
TestStep(11, "Read MPTZPosition. Verify the Pan value is set to PanMax."),
67-
TestStep(12, "If Tilt is supported, read and verify the TiltMin attribute. If not skip to step 22"),
67+
TestStep(12, "If Tilt is supported, read and verify the TiltMin attribute. If not skip to step 20"),
6868
TestStep(13, "Read and verify the TiltMax attribute."),
6969
TestStep(14, "Create a valid value for a Tilt, calculate the relative distance from the current Tilt."),
7070
TestStep(15, "Set via MPTZRelativeMove command the relative Tilt. Verify success response."),
71-
TestStep(16, "Read MPTZPosition. Verify the Tilt value is that set in Step 17."),
71+
TestStep(16, "Read MPTZPosition. Verify the Tilt value is that set in Step 15. Verify that Pan and Zoom are unchanged."),
7272
TestStep(17, "Create an invalid value for a relative Tilt that would exceed TiltMax."),
7373
TestStep(18, "Set via MPTZSetRelativeMove command the relative Tilt. Verify success response."),
7474
TestStep(19, "Read MPTZPosition. Verify the Tilt value is set to TiltMax."),
7575
TestStep(20, "If Zoom is supported, read and verify the ZoomMax attribute."),
7676
TestStep(21, "Create a valid value for a Zoom, calculate the relative distance from the current Zoom."),
7777
TestStep(22, "Set via MPTZRelativeMove command the relative Zoom. Verify success response."),
78-
TestStep(23, "Read MPTZPosition. Verify the Zoom value is that set in Step 24."),
78+
TestStep(23, "Read MPTZPosition. Verify the Zoom value is that set in Step 22. Verify the Pan and Tilt are unchanged"),
7979
TestStep(24, "Create an invalid value for a relative Zoom that would exceed ZoomMax."),
8080
TestStep(25, "Set via MPTZSetRelativeMove command the relative Zoom. Verify success response."),
8181
TestStep(26, "Read MPTZPosition. Verify the Zoom value is set to ZoomMax."),
82-
TestStep(27, "If PIXIT.CANBEMADEBUSY is set, place the DUT into a state where it cannot accept a command. Else end the test cse."),
82+
TestStep(27, "If PIXIT.CANBEMADEBUSY is set, place the DUT into a state where it cannot accept a command. Else end the test case."),
8383
TestStep(28, "Send an MPTZRelativeMove Command with any previously set relative value. Verify busy failure response."),
8484
]
8585
return steps
@@ -112,9 +112,9 @@ async def test_TC_AVSUM_2_3(self):
112112
asserts.assert_in(attributes.MPTZPosition.attribute_id, attribute_list,
113113
"MPTZPosition attribute is mandatory for command support.")
114114
mptzposition_dut = await self.read_avsum_attribute_expect_success(endpoint, attributes.MPTZPosition)
115-
initialPan = mptzposition_dut.pan
116-
initialTilt = mptzposition_dut.tilt
117-
initialZoom = mptzposition_dut.zoom
115+
currentPan = mptzposition_dut.pan
116+
currentTilt = mptzposition_dut.tilt
117+
currentZoom = mptzposition_dut.zoom
118118

119119
self.step(3)
120120
await self.send_null_mptz_relative_move_command(endpoint, expected_status=Status.InvalidCommand)
@@ -140,11 +140,11 @@ async def test_TC_AVSUM_2_3(self):
140140
# Create new Value for Pan
141141
while True:
142142
newPan = random.randint(pan_min_dut+1, pan_max_dut)
143-
if newPan != initialPan:
143+
if newPan != currentPan:
144144
break
145145

146146
# Calulate the difference, this is the relative move
147-
relativePan = abs(initialPan - newPan) if (initialPan < newPan) else -abs(newPan - initialPan)
147+
relativePan = abs(currentPan - newPan) if (currentPan < newPan) else -abs(newPan - currentPan)
148148

149149
self.step(7)
150150
# Invoke the command with the new Pan value
@@ -154,6 +154,9 @@ async def test_TC_AVSUM_2_3(self):
154154
# Read the attribute back and make sure it was set
155155
newpan_mptzposition_dut = await self.read_avsum_attribute_expect_success(endpoint, attributes.MPTZPosition)
156156
asserts.assert_equal(newpan_mptzposition_dut.pan, newPan, "Received Pan does not match set Pan")
157+
asserts.assert_equal(newpan_mptzposition_dut.tilt, currentTilt, "Tilt unexpectedly changed when only changing Pan")
158+
asserts.assert_equal(newpan_mptzposition_dut.zoom, currentZoom, "Zoom unexpectedly changed when only changing Pan")
159+
currentPan = newPan
157160

158161
self.step(9)
159162
# Create an out of range value for Pan, verify it's clipped to PanMax
@@ -165,6 +168,8 @@ async def test_TC_AVSUM_2_3(self):
165168
self.step(11)
166169
newpan_mptzposition_dut = await self.read_avsum_attribute_expect_success(endpoint, attributes.MPTZPosition)
167170
asserts.assert_equal(newpan_mptzposition_dut.pan, pan_max_dut, "Received Pan does not match PanMax")
171+
currentPan = pan_max_dut
172+
168173
else:
169174
self.skip_step(4)
170175
self.skip_step(5)
@@ -194,10 +199,10 @@ async def test_TC_AVSUM_2_3(self):
194199
# Create new Value for Tilt
195200
while True:
196201
newTilt = random.randint(tilt_min_dut+1, tilt_max_dut)
197-
if newTilt != initialTilt:
202+
if newTilt != currentTilt:
198203
break
199204

200-
relativeTilt = abs(initialTilt - newTilt) if (initialTilt < newTilt) else -abs(newTilt - initialTilt)
205+
relativeTilt = abs(currentTilt - newTilt) if (currentTilt < newTilt) else -abs(newTilt - currentTilt)
201206

202207
self.step(15)
203208
# Invoke the command with the new Tilt value
@@ -207,6 +212,9 @@ async def test_TC_AVSUM_2_3(self):
207212
# Read the attribute back and make sure it was set
208213
newtilt_mptzposition_dut = await self.read_avsum_attribute_expect_success(endpoint, attributes.MPTZPosition)
209214
asserts.assert_equal(newtilt_mptzposition_dut.tilt, newTilt, "Received Tilt does not match set Tilt")
215+
asserts.assert_equal(newtilt_mptzposition_dut.pan, currentPan, "Pan unexpectedly changed when only changing Tilt")
216+
asserts.assert_equal(newtilt_mptzposition_dut.zoom, currentZoom, "Zoom unexpectedly changed when only changing Tilt")
217+
currentTilt = newTilt
210218

211219
self.step(17)
212220
# Create an out of range value for Tilt, verify it's clipped to TiltMax
@@ -218,6 +226,8 @@ async def test_TC_AVSUM_2_3(self):
218226
self.step(19)
219227
newtilt_mptzposition_dut = await self.read_avsum_attribute_expect_success(endpoint, attributes.MPTZPosition)
220228
asserts.assert_equal(newtilt_mptzposition_dut.tilt, tilt_max_dut, "Received Tilt does not match TiltMax")
229+
currentTilt = tilt_max_dut
230+
221231
else:
222232
self.skip_step(12)
223233
self.skip_step(13)
@@ -240,10 +250,10 @@ async def test_TC_AVSUM_2_3(self):
240250
# Create new Value for Zoom
241251
while True:
242252
newZoom = random.randint(2, zoom_max_dut)
243-
if newZoom != initialZoom:
253+
if newZoom != currentZoom:
244254
break
245255

246-
relativeZoom = abs(initialZoom - newZoom) if (initialZoom < newZoom) else -abs(newZoom - initialZoom)
256+
relativeZoom = abs(currentZoom - newZoom) if (currentZoom < newZoom) else -abs(newZoom - currentZoom)
247257

248258
self.step(22)
249259
# Invoke the command with the new Zoom value
@@ -253,6 +263,8 @@ async def test_TC_AVSUM_2_3(self):
253263
# Read the attribute back and make sure it was set
254264
newzoom_mptzposition_dut = await self.read_avsum_attribute_expect_success(endpoint, attributes.MPTZPosition)
255265
asserts.assert_equal(newzoom_mptzposition_dut.zoom, newZoom, "Received Zoom does not match set Zoom")
266+
asserts.assert_equal(newzoom_mptzposition_dut.pan, currentPan, "Pan unexpectedly changed when only changing Zoom")
267+
asserts.assert_equal(newzoom_mptzposition_dut.tilt, currentTilt, "Tilt unexpectedly changed when only changing Zoom")
256268

257269
self.step(24)
258270
# Create an out of range value for Zoom, verify it's clipped to ZoomMax

0 commit comments

Comments
 (0)