mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Clean up test code
This commit is contained in:
parent
4096a67251
commit
76f63ee262
@ -52,30 +52,28 @@ def mock_service(hass, domain, service):
|
|||||||
return calls
|
return calls
|
||||||
|
|
||||||
|
|
||||||
|
def fire_time_changed(hass, time):
|
||||||
|
hass.bus.fire(EVENT_TIME_CHANGED, {'now': time})
|
||||||
|
|
||||||
|
|
||||||
def trigger_device_tracker_scan(hass):
|
def trigger_device_tracker_scan(hass):
|
||||||
""" Triggers the device tracker to scan. """
|
""" Triggers the device tracker to scan. """
|
||||||
hass.bus.fire(
|
fire_time_changed(
|
||||||
EVENT_TIME_CHANGED,
|
hass, dt_util.utcnow().replace(second=0) + timedelta(hours=1))
|
||||||
{'now':
|
|
||||||
dt_util.utcnow().replace(second=0) + timedelta(hours=1)})
|
|
||||||
|
|
||||||
|
|
||||||
def ensure_sun_risen(hass):
|
def ensure_sun_risen(hass):
|
||||||
""" Trigger sun to rise if below horizon. """
|
""" Trigger sun to rise if below horizon. """
|
||||||
if not sun.is_on(hass):
|
if sun.is_on(hass):
|
||||||
hass.bus.fire(
|
return
|
||||||
EVENT_TIME_CHANGED,
|
fire_time_changed(hass, sun.next_rising_utc(hass) + timedelta(seconds=10))
|
||||||
{'now':
|
|
||||||
sun.next_rising_utc(hass) + timedelta(seconds=10)})
|
|
||||||
|
|
||||||
|
|
||||||
def ensure_sun_set(hass):
|
def ensure_sun_set(hass):
|
||||||
""" Trigger sun to set if above horizon. """
|
""" Trigger sun to set if above horizon. """
|
||||||
if sun.is_on(hass):
|
if not sun.is_on(hass):
|
||||||
hass.bus.fire(
|
return
|
||||||
EVENT_TIME_CHANGED,
|
fire_time_changed(hass, sun.next_setting_utc(hass) + timedelta(seconds=10))
|
||||||
{'now':
|
|
||||||
sun.next_setting_utc(hass) + timedelta(seconds=10)})
|
|
||||||
|
|
||||||
|
|
||||||
def mock_state_change_event(hass, new_state, old_state=None):
|
def mock_state_change_event(hass, new_state, old_state=None):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user