mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Fix test_wait_template_with_utcnow (#45356)
This commit is contained in:
parent
96448c6778
commit
243014bff1
@ -824,6 +824,8 @@ async def test_wait_template_with_utcnow(hass):
|
|||||||
start_time = dt_util.utcnow().replace(minute=1) + timedelta(hours=48)
|
start_time = dt_util.utcnow().replace(minute=1) + timedelta(hours=48)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
non_maching_time = start_time.replace(hour=3)
|
||||||
|
with patch("homeassistant.util.dt.utcnow", return_value=non_maching_time):
|
||||||
hass.async_create_task(script_obj.async_run(context=Context()))
|
hass.async_create_task(script_obj.async_run(context=Context()))
|
||||||
await asyncio.wait_for(wait_started_flag.wait(), 1)
|
await asyncio.wait_for(wait_started_flag.wait(), 1)
|
||||||
assert script_obj.is_running
|
assert script_obj.is_running
|
||||||
@ -848,13 +850,17 @@ async def test_wait_template_with_utcnow_no_match(hass):
|
|||||||
timed_out = False
|
timed_out = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
non_maching_time = start_time.replace(hour=3)
|
||||||
|
with patch("homeassistant.util.dt.utcnow", return_value=non_maching_time):
|
||||||
hass.async_create_task(script_obj.async_run(context=Context()))
|
hass.async_create_task(script_obj.async_run(context=Context()))
|
||||||
await asyncio.wait_for(wait_started_flag.wait(), 1)
|
await asyncio.wait_for(wait_started_flag.wait(), 1)
|
||||||
assert script_obj.is_running
|
assert script_obj.is_running
|
||||||
|
|
||||||
non_maching_time = start_time.replace(hour=3)
|
second_non_maching_time = start_time.replace(hour=4)
|
||||||
with patch("homeassistant.util.dt.utcnow", return_value=non_maching_time):
|
with patch(
|
||||||
async_fire_time_changed(hass, non_maching_time)
|
"homeassistant.util.dt.utcnow", return_value=second_non_maching_time
|
||||||
|
):
|
||||||
|
async_fire_time_changed(hass, second_non_maching_time)
|
||||||
|
|
||||||
with timeout(0.1):
|
with timeout(0.1):
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user