@@ -1992,7 +1992,8 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
19921992 )
19931993 mock_stick_controller .send_response = sed_config_failed
19941994 await test_sed ._awake_response (awake_response1 ) # pylint: disable=protected-access
1995- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
1995+ assert test_sed ._delayed_task is not None # pylint: disable=protected-access
1996+ await asyncio .wait_for (asyncio .shield (test_sed ._delayed_task ), timeout = 2 )
19961997 assert test_sed .battery_config .dirty
19971998 assert test_sed .battery_config .awake_duration == 15
19981999 assert test_sed .awake_duration == 15
@@ -2009,7 +2010,8 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
20092010 assert test_sed .battery_config .dirty
20102011 mock_stick_controller .send_response = sed_config_accepted
20112012 await test_sed ._awake_response (awake_response2 ) # pylint: disable=protected-access
2012- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2013+ assert test_sed ._delayed_task is not None # pylint: disable=protected-access
2014+ await asyncio .wait_for (asyncio .shield (test_sed ._delayed_task ), timeout = 2 )
20132015 assert not test_sed .battery_config .dirty
20142016 assert test_sed .battery_config .awake_duration == 20
20152017 assert test_sed .awake_duration == 20
@@ -2033,7 +2035,8 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
20332035 seconds = pw_sed .AWAKE_RETRY
20342036 )
20352037 await test_sed ._awake_response (awake_response3 ) # pylint: disable=protected-access
2036- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2038+ assert test_sed ._delayed_task is not None # pylint: disable=protected-access
2039+ await asyncio .wait_for (asyncio .shield (test_sed ._delayed_task ), timeout = 2 )
20372040 assert not test_sed .battery_config .dirty
20382041 assert test_sed .battery_config .maintenance_interval == 30
20392042 assert test_sed .maintenance_interval == 30
@@ -2057,7 +2060,8 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
20572060 seconds = pw_sed .AWAKE_RETRY
20582061 )
20592062 await test_sed ._awake_response (awake_response4 ) # pylint: disable=protected-access
2060- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2063+ assert test_sed ._delayed_task is not None # pylint: disable=protected-access
2064+ await asyncio .wait_for (asyncio .shield (test_sed ._delayed_task ), timeout = 2 )
20612065 assert not test_sed .battery_config .dirty
20622066 assert test_sed .battery_config .clock_interval == 15000
20632067 assert test_sed .clock_interval == 15000
@@ -2076,7 +2080,8 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
20762080 seconds = pw_sed .AWAKE_RETRY
20772081 )
20782082 await test_sed ._awake_response (awake_response5 ) # pylint: disable=protected-access
2079- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2083+ assert test_sed ._delayed_task is not None # pylint: disable=protected-access
2084+ await asyncio .wait_for (asyncio .shield (test_sed ._delayed_task ), timeout = 2 )
20802085 assert not test_sed .battery_config .dirty
20812086 assert test_sed .battery_config .clock_sync
20822087 assert test_sed .clock_sync
@@ -2099,7 +2104,8 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
20992104 seconds = pw_sed .AWAKE_RETRY
21002105 )
21012106 await test_sed ._awake_response (awake_response6 ) # pylint: disable=protected-access
2102- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2107+ assert test_sed ._delayed_task is not None # pylint: disable=protected-access
2108+ await asyncio .wait_for (asyncio .shield (test_sed ._delayed_task ), timeout = 2 )
21032109 assert not test_sed .battery_config .dirty
21042110 assert test_sed .battery_config .sleep_duration == 120
21052111 assert test_sed .sleep_duration == 120
@@ -2204,7 +2210,8 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
22042210 )
22052211 mock_stick_controller .send_response = scan_config_failed
22062212 await test_scan ._awake_response (awake_response1 ) # pylint: disable=protected-access
2207- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2213+ assert test_scan ._delayed_task is not None # pylint: disable=protected-access
2214+ await asyncio .wait_for (asyncio .shield (test_scan ._delayed_task ), timeout = 2 )
22082215 assert test_scan .motion_config .dirty
22092216
22102217 # Successful config
@@ -2219,7 +2226,8 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
22192226 assert await test_scan .set_motion_reset_timer (25 )
22202227 assert test_scan .motion_config .dirty
22212228 await test_scan ._awake_response (awake_response2 ) # pylint: disable=protected-access
2222- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2229+ assert test_scan ._delayed_task is not None # pylint: disable=protected-access
2230+ await asyncio .wait_for (asyncio .shield (test_scan ._delayed_task ), timeout = 2 )
22232231 assert not test_scan .motion_config .dirty
22242232 assert test_scan .reset_timer == 25
22252233 assert test_scan .motion_config .reset_timer == 25
@@ -2239,7 +2247,8 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
22392247 seconds = pw_sed .AWAKE_RETRY
22402248 )
22412249 await test_scan ._awake_response (awake_response3 ) # pylint: disable=protected-access
2242- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2250+ assert test_scan ._delayed_task is not None # pylint: disable=protected-access
2251+ await asyncio .wait_for (asyncio .shield (test_scan ._delayed_task ), timeout = 2 )
22432252 assert not test_scan .motion_config .dirty
22442253 assert test_scan .daylight_mode
22452254 assert test_scan .motion_config .daylight_mode
@@ -2266,7 +2275,8 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
22662275 seconds = pw_sed .AWAKE_RETRY
22672276 )
22682277 await test_scan ._awake_response (awake_response4 ) # pylint: disable=protected-access
2269- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2278+ assert test_scan ._delayed_task is not None # pylint: disable=protected-access
2279+ await asyncio .wait_for (asyncio .shield (test_scan ._delayed_task ), timeout = 2 )
22702280 assert not test_scan .motion_config .dirty
22712281 assert test_scan .sensitivity_level == pw_api .MotionSensitivity .HIGH
22722282 assert (
@@ -2432,9 +2442,11 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
24322442 )
24332443 mock_stick_controller .send_response = sense_config_failed
24342444 await test_sense ._awake_response (awake_response1 ) # pylint: disable=protected-access
2435- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2445+ assert test_sense ._delayed_task is not None # pylint: disable=protected-access
2446+ await asyncio .wait_for (asyncio .shield (test_sense ._delayed_task ), timeout = 2 )
24362447 await test_sense ._awake_response (awake_response1 ) # pylint: disable=protected-access
2437- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2448+ assert test_sense ._delayed_task is not None # pylint: disable=protected-access
2449+ await asyncio .wait_for (asyncio .shield (test_sense ._delayed_task ), timeout = 2 )
24382450 assert test_sense .hysteresis_config_dirty
24392451
24402452 # Successful config
@@ -2447,9 +2459,11 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
24472459 )
24482460 mock_stick_controller .send_response = sense_config_accepted
24492461 await test_sense ._awake_response (awake_response2 ) # pylint: disable=protected-access
2450- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2462+ assert test_sense ._delayed_task is not None # pylint: disable=protected-access
2463+ await asyncio .wait_for (asyncio .shield (test_sense ._delayed_task ), timeout = 2 )
24512464 await test_sense ._awake_response (awake_response2 ) # pylint: disable=protected-access
2452- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2465+ assert test_sense ._delayed_task is not None # pylint: disable=protected-access
2466+ await asyncio .wait_for (asyncio .shield (test_sense ._delayed_task ), timeout = 2 )
24532467 assert not test_sense .hysteresis_config_dirty
24542468 assert test_sense .humidity_upper_bound == 65
24552469
@@ -2477,9 +2491,11 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
24772491 )
24782492 mock_stick_controller .send_response = sense_config_accepted
24792493 await test_sense ._awake_response (awake_response3 ) # pylint: disable=protected-access
2480- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2494+ assert test_sense ._delayed_task is not None # pylint: disable=protected-access
2495+ await asyncio .wait_for (asyncio .shield (test_sense ._delayed_task ), timeout = 2 )
24812496 await test_sense ._awake_response (awake_response3 ) # pylint: disable=protected-access
2482- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2497+ assert test_sense ._delayed_task is not None # pylint: disable=protected-access
2498+ await asyncio .wait_for (asyncio .shield (test_sense ._delayed_task ), timeout = 2 )
24832499 assert not test_sense .hysteresis_config_dirty
24842500 assert test_sense .humidity_lower_bound == 55
24852501
@@ -2511,9 +2527,11 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
25112527 )
25122528 mock_stick_controller .send_response = sense_config_failed
25132529 await test_sense ._awake_response (awake_response4 ) # pylint: disable=protected-access
2514- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2530+ assert test_sense ._delayed_task is not None # pylint: disable=protected-access
2531+ await asyncio .wait_for (asyncio .shield (test_sense ._delayed_task ), timeout = 2 )
25152532 await test_sense ._awake_response (awake_response4 ) # pylint: disable=protected-access
2516- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2533+ assert test_sense ._delayed_task is not None # pylint: disable=protected-access
2534+ await asyncio .wait_for (asyncio .shield (test_sense ._delayed_task ), timeout = 2 )
25172535 assert test_sense .hysteresis_config_dirty
25182536
25192537 # Successful config
@@ -2526,9 +2544,11 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
25262544 )
25272545 mock_stick_controller .send_response = sense_config_accepted
25282546 await test_sense ._awake_response (awake_response5 ) # pylint: disable=protected-access
2529- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2547+ assert test_sense ._delayed_task is not None # pylint: disable=protected-access
2548+ await asyncio .wait_for (asyncio .shield (test_sense ._delayed_task ), timeout = 2 )
25302549 await test_sense ._awake_response (awake_response5 ) # pylint: disable=protected-access
2531- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2550+ assert test_sense ._delayed_task is not None # pylint: disable=protected-access
2551+ await asyncio .wait_for (asyncio .shield (test_sense ._delayed_task ), timeout = 2 )
25322552 assert not test_sense .hysteresis_config_dirty
25332553 assert test_sense .temperature_upper_bound == 26
25342554
@@ -2556,9 +2576,11 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
25562576 )
25572577 mock_stick_controller .send_response = sense_config_accepted
25582578 await test_sense ._awake_response (awake_response6 ) # pylint: disable=protected-access
2559- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
2579+ assert test_sense ._delayed_task is not None # pylint: disable=protected-access
2580+ await asyncio .wait_for (asyncio .shield (test_sense ._delayed_task ), timeout = 2 )
2581+ assert test_sense ._delayed_task is not None # pylint: disable=protected-access
2582+ await asyncio .wait_for (asyncio .shield (test_sense ._delayed_task ), timeout = 2 )
25602583 await test_sense ._awake_response (awake_response6 ) # pylint: disable=protected-access
2561- await asyncio .sleep (0.001 ) # Ensure time for task to be executed
25622584 assert not test_sense .hysteresis_config_dirty
25632585 assert test_sense .temperature_lower_bound == 24
25642586
0 commit comments