Skip to content

Commit effde51

Browse files
authored
Python framework: Remove default from get_endpoint (project-chip#41711)
* Python framework: Remove default from get_endpoint In order to do test selection we need to know the endpoint before the test. if the default is set by the test explicitly outside of the test function call, we know. Ideally, all tests would be explicit about asking the tester to set the endpoint to avoid accidentally testing the wrong thing. However, the intent of this PR is not to change that policy, but rather to make the information available before the test function itself is run, either through the user command line parameter or through the static default. The functions inside tests were adjusted according to the following rules - get_endpoint calls in test_ functions with @run_if_endpoint_matches decorators just have the defaults removed. Those decorators already enforce that the endpoint parameter is given on the command line so the default would never be used. - get_endpoint calls in utility functions have the defaults removed since these should use the endpoint of the caller in the first place - get_endpoint calls with a default in functions decorated with the async_test_body decorator have an explicit default_endpoint property function defined to match the given default if the default is not 0 * Fix type annotation * A couple more * Fix doorlock * fix webrtcp-2.9 * fix a couple more * Fix two additional tests added after this PR was raised * missed one more * add default endpoints to door lock * I liked the function so much I thought...why not two?
1 parent e123d28 commit effde51

File tree

174 files changed

+629
-191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+629
-191
lines changed

src/python_testing/TC_AVSMTestBase.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def predicate(report: AttributeValue) -> bool:
4949

5050
class AVSMTestBase:
5151
async def precondition_one_allocated_snapshot_stream(self):
52-
endpoint = self.get_endpoint(default=1)
52+
endpoint = self.get_endpoint()
5353
cluster = Clusters.CameraAvStreamManagement
5454
attr = Clusters.CameraAvStreamManagement.Attributes
5555
commands = Clusters.CameraAvStreamManagement.Commands
@@ -100,7 +100,7 @@ async def precondition_one_allocated_snapshot_stream(self):
100100
pass
101101

102102
async def precondition_one_allocated_audio_stream(self, streamUsage: Globals.Enums.StreamUsageEnum = None):
103-
endpoint = self.get_endpoint(default=1)
103+
endpoint = self.get_endpoint()
104104
cluster = Clusters.CameraAvStreamManagement
105105
attr = Clusters.CameraAvStreamManagement.Attributes
106106
commands = Clusters.CameraAvStreamManagement.Commands
@@ -154,7 +154,7 @@ async def precondition_one_allocated_audio_stream(self, streamUsage: Globals.Enu
154154
pass
155155

156156
async def precondition_one_allocated_video_stream(self, streamUsage: Globals.Enums.StreamUsageEnum = None):
157-
endpoint = self.get_endpoint(default=1)
157+
endpoint = self.get_endpoint()
158158
cluster = Clusters.CameraAvStreamManagement
159159
attr = Clusters.CameraAvStreamManagement.Attributes
160160
commands = Clusters.CameraAvStreamManagement.Commands

src/python_testing/TC_AVSM_2_1.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,13 @@ def steps_TC_AVSM_2_1(self) -> list[TestStep]:
150150
),
151151
]
152152

153+
@property
154+
def default_endpoint(self) -> int:
155+
return 1
156+
153157
@async_test_body
154158
async def test_TC_AVSM_2_1(self):
155-
endpoint = self.get_endpoint(default=1)
159+
endpoint = self.get_endpoint()
156160
cluster = Clusters.CameraAvStreamManagement
157161
attr = Clusters.CameraAvStreamManagement.Attributes
158162

src/python_testing/TC_AVSM_2_10.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def steps_TC_AVSM_2_10(self) -> list[TestStep]:
114114
has_feature(Clusters.CameraAvStreamManagement, Clusters.CameraAvStreamManagement.Bitmaps.Feature.kSnapshot)
115115
)
116116
async def test_TC_AVSM_2_10(self):
117-
endpoint = self.get_endpoint(default=1)
117+
endpoint = self.get_endpoint()
118118
cluster = Clusters.CameraAvStreamManagement
119119
attr = Clusters.CameraAvStreamManagement.Attributes
120120
commands = Clusters.CameraAvStreamManagement.Commands

src/python_testing/TC_AVSM_2_11.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def steps_TC_AVSM_2_11(self) -> list[TestStep]:
116116
and has_feature(Clusters.CameraAvStreamManagement, Clusters.CameraAvStreamManagement.Bitmaps.Feature.kVideo)
117117
)
118118
async def test_TC_AVSM_2_11(self):
119-
endpoint = self.get_endpoint(default=1)
119+
endpoint = self.get_endpoint()
120120
cluster = Clusters.CameraAvStreamManagement
121121
attr = Clusters.CameraAvStreamManagement.Attributes
122122
commands = Clusters.CameraAvStreamManagement.Commands

src/python_testing/TC_AVSM_2_12.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def steps_TC_AVSM_2_12(self) -> list[TestStep]:
160160

161161
@run_if_endpoint_matches(has_cluster(Clusters.CameraAvStreamManagement))
162162
async def test_TC_AVSM_2_12(self):
163-
endpoint = self.get_endpoint(default=1)
163+
endpoint = self.get_endpoint()
164164
cluster = Clusters.CameraAvStreamManagement
165165
attr = Clusters.CameraAvStreamManagement.Attributes
166166

src/python_testing/TC_AVSM_2_13.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def steps_TC_AVSM_2_13(self) -> list[TestStep]:
117117
has_feature(Clusters.CameraAvStreamManagement, Clusters.CameraAvStreamManagement.Bitmaps.Feature.kVideo)
118118
)
119119
async def test_TC_AVSM_2_13(self):
120-
endpoint = self.get_endpoint(default=1)
120+
endpoint = self.get_endpoint()
121121
cluster = Clusters.CameraAvStreamManagement
122122
attr = Clusters.CameraAvStreamManagement.Attributes
123123
commands = Clusters.CameraAvStreamManagement.Commands

src/python_testing/TC_AVSM_2_14.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def steps_TC_AVSM_2_14(self) -> list[TestStep]:
102102
has_feature(Clusters.CameraAvStreamManagement, Clusters.CameraAvStreamManagement.Bitmaps.Feature.kAudio)
103103
)
104104
async def test_TC_AVSM_2_14(self):
105-
endpoint = self.get_endpoint(default=1)
105+
endpoint = self.get_endpoint()
106106
cluster = Clusters.CameraAvStreamManagement
107107
attr = Clusters.CameraAvStreamManagement.Attributes
108108
commands = Clusters.CameraAvStreamManagement.Commands

src/python_testing/TC_AVSM_2_15.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def steps_TC_AVSM_2_15(self) -> list[TestStep]:
9797
has_feature(Clusters.CameraAvStreamManagement, Clusters.CameraAvStreamManagement.Bitmaps.Feature.kSnapshot)
9898
)
9999
async def test_TC_AVSM_2_15(self):
100-
endpoint = self.get_endpoint(default=1)
100+
endpoint = self.get_endpoint()
101101
cluster = Clusters.CameraAvStreamManagement
102102
attr = Clusters.CameraAvStreamManagement.Attributes
103103
commands = Clusters.CameraAvStreamManagement.Commands

src/python_testing/TC_AVSM_2_16.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def steps_TC_AVSM_2_16(self) -> list[TestStep]:
144144
has_feature(Clusters.CameraAvStreamManagement, Clusters.CameraAvStreamManagement.Bitmaps.Feature.kVideo) and
145145
has_feature(Clusters.CameraAvStreamManagement, Clusters.CameraAvStreamManagement.Bitmaps.Feature.kAudio))
146146
async def test_TC_AVSM_2_16(self):
147-
endpoint = self.get_endpoint(default=1)
147+
endpoint = self.get_endpoint()
148148
cluster = Clusters.CameraAvStreamManagement
149149
attr = Clusters.CameraAvStreamManagement.Attributes
150150
commands = Clusters.CameraAvStreamManagement.Commands

src/python_testing/TC_AVSM_2_17.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def steps_TC_AVSM_2_17(self) -> list[TestStep]:
173173
and has_feature(Clusters.CameraAvStreamManagement, Clusters.CameraAvStreamManagement.Bitmaps.Feature.kPrivacy)
174174
)
175175
async def test_TC_AVSM_2_17(self):
176-
endpoint = self.get_endpoint(default=1)
176+
endpoint = self.get_endpoint()
177177
cluster = Clusters.CameraAvStreamManagement
178178
attr = Clusters.CameraAvStreamManagement.Attributes
179179
commands = Clusters.CameraAvStreamManagement.Commands

0 commit comments

Comments
 (0)