mirror of
https://github.com/esphome/esphome.git
synced 2025-08-01 16:07:47 +00:00
faster test
This commit is contained in:
parent
34ef07cd58
commit
27e8ddbf3c
@ -8,7 +8,7 @@ api:
|
|||||||
then:
|
then:
|
||||||
- logger.log: "Starting first script execution"
|
- logger.log: "Starting first script execution"
|
||||||
- script.execute: test_delay_script
|
- script.execute: test_delay_script
|
||||||
- delay: 500ms # Give first script time to start delay
|
- delay: 250ms # Give first script time to start delay
|
||||||
- logger.log: "Restarting script (should cancel first delay)"
|
- logger.log: "Restarting script (should cancel first delay)"
|
||||||
- script.execute: test_delay_script
|
- script.execute: test_delay_script
|
||||||
|
|
||||||
@ -20,5 +20,5 @@ script:
|
|||||||
mode: restart
|
mode: restart
|
||||||
then:
|
then:
|
||||||
- logger.log: "Script started, beginning delay"
|
- logger.log: "Script started, beginning delay"
|
||||||
- delay: 1s # Long enough that it won't complete before restart
|
- delay: 500ms # Long enough that it won't complete before restart
|
||||||
- logger.log: "Delay completed successfully"
|
- logger.log: "Delay completed successfully"
|
||||||
|
@ -73,7 +73,7 @@ async def test_delay_action_cancellation(
|
|||||||
await asyncio.wait_for(second_script_started, timeout=5.0)
|
await asyncio.wait_for(second_script_started, timeout=5.0)
|
||||||
|
|
||||||
# Wait for potential delay completion
|
# Wait for potential delay completion
|
||||||
await asyncio.sleep(1.5) # Original delay was 1s
|
await asyncio.sleep(0.75) # Original delay was 500ms
|
||||||
|
|
||||||
# Check results
|
# Check results
|
||||||
assert len(script_starts) == 2, (
|
assert len(script_starts) == 2, (
|
||||||
@ -86,6 +86,6 @@ async def test_delay_action_cancellation(
|
|||||||
f"Expected 1 delay completion, got {len(delay_completions)}"
|
f"Expected 1 delay completion, got {len(delay_completions)}"
|
||||||
)
|
)
|
||||||
time_from_second_start = delay_completions[0] - script_starts[1]
|
time_from_second_start = delay_completions[0] - script_starts[1]
|
||||||
assert 0.8 < time_from_second_start < 1.2, (
|
assert 0.4 < time_from_second_start < 0.6, (
|
||||||
f"Delay completed {time_from_second_start:.3f}s after second start, expected ~1s"
|
f"Delay completed {time_from_second_start:.3f}s after second start, expected ~0.5s"
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user