Remove EVENT_TIME_CHANGED and EVENT_TIMER_OUT_OF_SYNC (#69643)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
689b347904
commit
fe6a4bfb1d
44 changed files with 397 additions and 839 deletions
|
@ -1,7 +1,7 @@
|
|||
"""The tests for the sun automation."""
|
||||
from datetime import datetime
|
||||
from unittest.mock import patch
|
||||
|
||||
from freezegun import freeze_time
|
||||
import pytest
|
||||
|
||||
from homeassistant.components import sun
|
||||
|
@ -36,12 +36,12 @@ def setup_comp(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_sunset_trigger(hass, calls, legacy_patchable_time):
|
||||
async def test_sunset_trigger(hass, calls):
|
||||
"""Test the sunset trigger."""
|
||||
now = datetime(2015, 9, 15, 23, tzinfo=dt_util.UTC)
|
||||
trigger_time = datetime(2015, 9, 16, 2, tzinfo=dt_util.UTC)
|
||||
|
||||
with patch("homeassistant.util.dt.utcnow", return_value=now):
|
||||
with freeze_time(now):
|
||||
await async_setup_component(
|
||||
hass,
|
||||
automation.DOMAIN,
|
||||
|
@ -56,18 +56,18 @@ async def test_sunset_trigger(hass, calls, legacy_patchable_time):
|
|||
},
|
||||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
automation.DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY_MATCH_ALL},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.services.async_call(
|
||||
automation.DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY_MATCH_ALL},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
async_fire_time_changed(hass, trigger_time)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 0
|
||||
async_fire_time_changed(hass, trigger_time)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 0
|
||||
|
||||
with patch("homeassistant.util.dt.utcnow", return_value=now):
|
||||
with freeze_time(now):
|
||||
await hass.services.async_call(
|
||||
automation.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
|
@ -75,18 +75,18 @@ async def test_sunset_trigger(hass, calls, legacy_patchable_time):
|
|||
blocking=True,
|
||||
)
|
||||
|
||||
async_fire_time_changed(hass, trigger_time)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data["id"] == 0
|
||||
async_fire_time_changed(hass, trigger_time)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data["id"] == 0
|
||||
|
||||
|
||||
async def test_sunrise_trigger(hass, calls, legacy_patchable_time):
|
||||
async def test_sunrise_trigger(hass, calls):
|
||||
"""Test the sunrise trigger."""
|
||||
now = datetime(2015, 9, 13, 23, tzinfo=dt_util.UTC)
|
||||
trigger_time = datetime(2015, 9, 16, 14, tzinfo=dt_util.UTC)
|
||||
|
||||
with patch("homeassistant.util.dt.utcnow", return_value=now):
|
||||
with freeze_time(now):
|
||||
await async_setup_component(
|
||||
hass,
|
||||
automation.DOMAIN,
|
||||
|
@ -98,17 +98,17 @@ async def test_sunrise_trigger(hass, calls, legacy_patchable_time):
|
|||
},
|
||||
)
|
||||
|
||||
async_fire_time_changed(hass, trigger_time)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
async_fire_time_changed(hass, trigger_time)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
|
||||
|
||||
async def test_sunset_trigger_with_offset(hass, calls, legacy_patchable_time):
|
||||
async def test_sunset_trigger_with_offset(hass, calls):
|
||||
"""Test the sunset trigger with offset."""
|
||||
now = datetime(2015, 9, 15, 23, tzinfo=dt_util.UTC)
|
||||
trigger_time = datetime(2015, 9, 16, 2, 30, tzinfo=dt_util.UTC)
|
||||
|
||||
with patch("homeassistant.util.dt.utcnow", return_value=now):
|
||||
with freeze_time(now):
|
||||
await async_setup_component(
|
||||
hass,
|
||||
automation.DOMAIN,
|
||||
|
@ -130,18 +130,18 @@ async def test_sunset_trigger_with_offset(hass, calls, legacy_patchable_time):
|
|||
},
|
||||
)
|
||||
|
||||
async_fire_time_changed(hass, trigger_time)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data["some"] == "sun - sunset - 0:30:00"
|
||||
async_fire_time_changed(hass, trigger_time)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data["some"] == "sun - sunset - 0:30:00"
|
||||
|
||||
|
||||
async def test_sunrise_trigger_with_offset(hass, calls, legacy_patchable_time):
|
||||
async def test_sunrise_trigger_with_offset(hass, calls):
|
||||
"""Test the sunrise trigger with offset."""
|
||||
now = datetime(2015, 9, 13, 23, tzinfo=dt_util.UTC)
|
||||
trigger_time = datetime(2015, 9, 16, 13, 30, tzinfo=dt_util.UTC)
|
||||
|
||||
with patch("homeassistant.util.dt.utcnow", return_value=now):
|
||||
with freeze_time(now):
|
||||
await async_setup_component(
|
||||
hass,
|
||||
automation.DOMAIN,
|
||||
|
@ -157,6 +157,6 @@ async def test_sunrise_trigger_with_offset(hass, calls, legacy_patchable_time):
|
|||
},
|
||||
)
|
||||
|
||||
async_fire_time_changed(hass, trigger_time)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
async_fire_time_changed(hass, trigger_time)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue