Skip to content

Commit 1a30459

Browse files
restyled-commitstcarmelveilleux
authored andcommitted
Restyled by autopep8
1 parent ca59fd9 commit 1a30459

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

src/python_testing/TC_SWTCH.py

+19-9
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
logger = logging.getLogger(__name__)
4343

44+
4445
class TC_SwitchTests(MatterBaseTest):
4546
def __init__(self, *args, **kwargs):
4647
super().__init__(*args, **kwargs)
@@ -85,9 +86,11 @@ def _ask_for_switch_idle(self):
8586

8687
def _ask_for_long_press(self, endpoint_id: int, pressed_position: int):
8788
if not self._use_button_simulator():
88-
self.wait_for_user_input(prompt_msg=f"Press switch position {pressed_position} for a long time (around 5 seconds) on the DUT, then release it.")
89+
self.wait_for_user_input(
90+
prompt_msg=f"Press switch position {pressed_position} for a long time (around 5 seconds) on the DUT, then release it.")
8991
else:
90-
command_dict = {"Name": "SimulateActionSwitchLongPress", "EndpointId": endpoint_id, "ButtonId": pressed_position, "LongPressDelayMillis": 5000, "LongPressDurationMillis": 5500}
92+
command_dict = {"Name": "SimulateActionSwitchLongPress", "EndpointId": endpoint_id,
93+
"ButtonId": pressed_position, "LongPressDelayMillis": 5000, "LongPressDurationMillis": 5500}
9194
self._send_named_pipe_command(command_dict)
9295

9396
def _placeholder_for_step(self, step_id: str):
@@ -120,7 +123,8 @@ def _await_sequence_of_reports(self, report_queue: queue.Queue, endpoint_id: int
120123
logging.info(f"Got expected attribute change {sequence_idx+1}/{len(sequence)} for attribute {attribute}")
121124
sequence_idx += 1
122125
else:
123-
asserts.assert_equal(item.value, expected_value, msg="Did not get expected attribute value in correct sequence.")
126+
asserts.assert_equal(item.value, expected_value,
127+
msg="Did not get expected attribute value in correct sequence.")
124128

125129
# We are done waiting when we have accumulated all results.
126130
if sequence_idx == len(sequence):
@@ -244,14 +248,17 @@ async def test_TC_SWTCH_2_4(self):
244248

245249
# Step 4b: TH expects report of CurrentPosition 1, followed by a report of Current Position 0.
246250
self._placeholder_for_step("4b")
247-
logging.info(f"Starting to wait for {post_prompt_settle_delay_seconds:.1f} seconds for CurrentPosition to go {switch_pressed_position}, then 0.")
248-
self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.CurrentPosition, sequence = [switch_pressed_position, 0], timeout_sec=post_prompt_settle_delay_seconds)
251+
logging.info(
252+
f"Starting to wait for {post_prompt_settle_delay_seconds:.1f} seconds for CurrentPosition to go {switch_pressed_position}, then 0.")
253+
self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.CurrentPosition, sequence=[
254+
switch_pressed_position, 0], timeout_sec=post_prompt_settle_delay_seconds)
249255

250256
# Step 4c: TH expects at least InitialPress with NewPosition = 1
251257
self._placeholder_for_step("4c")
252258
logging.info(f"Starting to wait for {post_prompt_settle_delay_seconds:.1f} seconds for InitialPress event.")
253259
expected_events = [cluster.Events.InitialPress(newPosition=switch_pressed_position)]
254-
self._await_sequence_of_events(event_queue=event_listener.event_queue, endpoint_id=endpoint_id, sequence=expected_events, timeout_sec=post_prompt_settle_delay_seconds)
260+
self._await_sequence_of_events(event_queue=event_listener.event_queue, endpoint_id=endpoint_id,
261+
sequence=expected_events, timeout_sec=post_prompt_settle_delay_seconds)
255262

256263
# Step 4d: For MSL/AS, expect to see LongPress/LongRelease in that order
257264
if not has_msl_feature and not has_as_feature:
@@ -264,18 +271,21 @@ async def test_TC_SWTCH_2_4(self):
264271
expected_events = []
265272
expected_events.append(cluster.Events.LongPress(newPosition=switch_pressed_position))
266273
expected_events.append(cluster.Events.LongRelease(previousPosition=switch_pressed_position))
267-
self._await_sequence_of_events(event_queue=event_listener.event_queue, endpoint_id=endpoint_id, sequence=expected_events, timeout_sec=post_prompt_settle_delay_seconds)
274+
self._await_sequence_of_events(event_queue=event_listener.event_queue, endpoint_id=endpoint_id,
275+
sequence=expected_events, timeout_sec=post_prompt_settle_delay_seconds)
268276

269277
# Step 4e: For MS & (!MSL & !AS & !MSR), expect no further events for 10 seconds.
270278
if not has_msl_feature and not has_as_feature and not has_msr_feature:
271279
self._placeholder_for_step("4e")
272-
self._expect_no_events_for_cluster(event_queue=event_listener.event_queue, endpoint_id=endpoint_id, expected_cluster=cluster, timeout_sec=10.0)
280+
self._expect_no_events_for_cluster(event_queue=event_listener.event_queue,
281+
endpoint_id=endpoint_id, expected_cluster=cluster, timeout_sec=10.0)
273282

274283
# Step 4f: For MSR & not MSL, expect to see ShortRelease.
275284
if not has_msl_feature and has_msr_feature:
276285
self._placeholder_for_step("4f")
277286
expected_events = [cluster.Events.ShortRelease(previousPosition=switch_pressed_position)]
278-
self._await_sequence_of_events(event_queue=event_listener.event_queue, endpoint_id=endpoint_id, sequence=expected_events, timeout_sec=post_prompt_settle_delay_seconds)
287+
self._await_sequence_of_events(event_queue=event_listener.event_queue, endpoint_id=endpoint_id,
288+
sequence=expected_events, timeout_sec=post_prompt_settle_delay_seconds)
279289

280290

281291
if __name__ == "__main__":

src/python_testing/matter_testing_support.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,12 @@ def __init__(self, expected_cluster: ClusterObjects.Cluster):
238238
self._q = queue.Queue()
239239
self._expected_cluster = expected_cluster
240240

241-
async def start(self, dev_ctrl, node_id: int, endpoint: int, fabric_filtered: bool=False, min_interval_sec: int=0, max_interval_sec: int=30) -> Any:
241+
async def start(self, dev_ctrl, node_id: int, endpoint: int, fabric_filtered: bool = False, min_interval_sec: int = 0, max_interval_sec: int = 30) -> Any:
242242
"""This starts a subscription for events on the specified node_id and endpoint. The cluster is specified when the class instance is created."""
243243
urgent = True
244244
self._subscription = await dev_ctrl.ReadEvent(node_id,
245-
events=[(endpoint, self._expected_cluster, urgent)], reportInterval=(min_interval_sec, max_interval_sec),
245+
events=[(endpoint, self._expected_cluster, urgent)], reportInterval=(
246+
min_interval_sec, max_interval_sec),
246247
fabricFiltered=fabric_filtered, keepSubscriptions=True, autoResubscribe=False)
247248
self._subscription.SetEventUpdateCallback(self.__call__)
248249
return self._subscription
@@ -269,7 +270,7 @@ def wait_for_event_report(self, expected_event: ClusterObjects.ClusterEvent, tim
269270

270271
@property
271272
def event_queue(self) -> queue.Queue:
272-
return self._q
273+
return self._q
273274

274275

275276
class AttributeChangeCallback:
@@ -304,6 +305,7 @@ def wait_for_report(self):
304305
except KeyError:
305306
asserts.fail("[AttributeChangeCallback] Attribute {expected_attribute} not found in returned report")
306307

308+
307309
@dataclass
308310
class AttributeValue:
309311
endpoint_id: int
@@ -317,15 +319,15 @@ def __init__(self, expected_cluster: ClusterObjects.Cluster):
317319
self._expected_cluster = expected_cluster
318320
self._subscription = None
319321

320-
async def start(self, dev_ctrl, node_id: int, endpoint: int, fabric_filtered: bool=False, min_interval_sec: int=0, max_interval_sec: int=30) -> Any:
322+
async def start(self, dev_ctrl, node_id: int, endpoint: int, fabric_filtered: bool = False, min_interval_sec: int = 0, max_interval_sec: int = 30) -> Any:
321323
"""This starts a subscription for attributes on the specified node_id and endpoint. The cluster is specified when the class instance is created."""
322324
self._subscription = await dev_ctrl.ReadAttribute(
323-
nodeid=node_id,
324-
attributes=[(endpoint, self._expected_cluster)],
325-
reportInterval=(min_interval_sec, max_interval_sec),
326-
fabricFiltered=fabric_filtered,
327-
keepSubscriptions=True
328-
)
325+
nodeid=node_id,
326+
attributes=[(endpoint, self._expected_cluster)],
327+
reportInterval=(min_interval_sec, max_interval_sec),
328+
fabricFiltered=fabric_filtered,
329+
keepSubscriptions=True
330+
)
329331
self._subscription.SetAttributeUpdateCallback(self.__call__)
330332
return self._subscription
331333

0 commit comments

Comments
 (0)