Use const.SUN_EVENT_* more (#18039)
This commit is contained in:
1 parent
dcc46226ee
commit
9c840f93f0
11 files changed
+82
-67
No files matched your search
@@ -4,6 +4,7 @@ from datetime import datetime
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.const import SUN_EVENT_SUNRISE, SUN_EVENT_SUNSET
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.components import sun
|
||||
import homeassistant.components.automation as automation
|
||||
@@ -39,7 +40,7 @@ async def test_sunset_trigger(hass, calls):
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
'platform': 'sun',
|
||||
'event': 'sunset',
|
||||
'event': SUN_EVENT_SUNSET,
|
||||
},
|
||||
'action': {
|
||||
'service': 'test.automation',
|
||||
@@ -75,7 +76,7 @@ async def test_sunrise_trigger(hass, calls):
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
'platform': 'sun',
|
||||
'event': 'sunrise',
|
||||
'event': SUN_EVENT_SUNRISE,
|
||||
},
|
||||
'action': {
|
||||
'service': 'test.automation',
|
||||
@@ -99,7 +100,7 @@ async def test_sunset_trigger_with_offset(hass, calls):
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
'platform': 'sun',
|
||||
'event': 'sunset',
|
||||
'event': SUN_EVENT_SUNSET,
|
||||
'offset': '0:30:00'
|
||||
},
|
||||
'action': {
|
||||
@@ -130,7 +131,7 @@ async def test_sunrise_trigger_with_offset(hass, calls):
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
'platform': 'sun',
|
||||
'event': 'sunrise',
|
||||
'event': SUN_EVENT_SUNRISE,
|
||||
'offset': '-0:30:00'
|
||||
},
|
||||
'action': {
|
||||
@@ -154,7 +155,7 @@ async def test_if_action_before(hass, calls):
|
||||
},
|
||||
'condition': {
|
||||
'condition': 'sun',
|
||||
'before': 'sunrise',
|
||||
'before': SUN_EVENT_SUNRISE,
|
||||
},
|
||||
'action': {
|
||||
'service': 'test.automation'
|
||||
@@ -187,7 +188,7 @@ async def test_if_action_after(hass, calls):
|
||||
},
|
||||
'condition': {
|
||||
'condition': 'sun',
|
||||
'after': 'sunrise',
|
||||
'after': SUN_EVENT_SUNRISE,
|
||||
},
|
||||
'action': {
|
||||
'service': 'test.automation'
|
||||
@@ -220,7 +221,7 @@ async def test_if_action_before_with_offset(hass, calls):
|
||||
},
|
||||
'condition': {
|
||||
'condition': 'sun',
|
||||
'before': 'sunrise',
|
||||
'before': SUN_EVENT_SUNRISE,
|
||||
'before_offset': '+1:00:00'
|
||||
},
|
||||
'action': {
|
||||
@@ -254,7 +255,7 @@ async def test_if_action_after_with_offset(hass, calls):
|
||||
},
|
||||
'condition': {
|
||||
'condition': 'sun',
|
||||
'after': 'sunrise',
|
||||
'after': SUN_EVENT_SUNRISE,
|
||||
'after_offset': '+1:00:00'
|
||||
},
|
||||
'action': {
|
||||
@@ -288,8 +289,8 @@ async def test_if_action_before_and_after_during(hass, calls):
|
||||
},
|
||||
'condition': {
|
||||
'condition': 'sun',
|
||||
'after': 'sunrise',
|
||||
'before': 'sunset'
|
||||
'after': SUN_EVENT_SUNRISE,
|
||||
'before': SUN_EVENT_SUNSET
|
||||
},
|
||||
'action': {
|
||||
'service': 'test.automation'
|
||||
|
||||
@@ -4,7 +4,8 @@ from unittest.mock import patch
|
||||
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components import switch, light
|
||||
from homeassistant.const import CONF_PLATFORM, STATE_ON, SERVICE_TURN_ON
|
||||
from homeassistant.const import (
|
||||
CONF_PLATFORM, STATE_ON, SERVICE_TURN_ON, SUN_EVENT_SUNRISE)
|
||||
import homeassistant.loader as loader
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
@@ -91,7 +92,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
def event_date(hass, event, now=None):
|
||||
if event == 'sunrise':
|
||||
if event == SUN_EVENT_SUNRISE:
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
@@ -131,7 +132,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
def event_date(hass, event, now=None):
|
||||
if event == 'sunrise':
|
||||
if event == SUN_EVENT_SUNRISE:
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
@@ -176,7 +177,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
def event_date(hass, event, now=None):
|
||||
if event == 'sunrise':
|
||||
if event == SUN_EVENT_SUNRISE:
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
@@ -222,7 +223,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
def event_date(hass, event, now=None):
|
||||
if event == 'sunrise':
|
||||
if event == SUN_EVENT_SUNRISE:
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
@@ -269,7 +270,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
def event_date(hass, event, now=None):
|
||||
if event == 'sunrise':
|
||||
if event == SUN_EVENT_SUNRISE:
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
@@ -314,7 +315,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
def event_date(hass, event, now=None):
|
||||
if event == 'sunrise':
|
||||
if event == SUN_EVENT_SUNRISE:
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
@@ -364,7 +365,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
def event_date(hass, event, now=None):
|
||||
if event == 'sunrise':
|
||||
if event == SUN_EVENT_SUNRISE:
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
@@ -415,7 +416,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
def event_date(hass, event, now=None):
|
||||
if event == 'sunrise':
|
||||
if event == SUN_EVENT_SUNRISE:
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
@@ -465,7 +466,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
def event_date(hass, event, now=None):
|
||||
if event == 'sunrise':
|
||||
if event == SUN_EVENT_SUNRISE:
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
@@ -514,7 +515,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
def event_date(hass, event, now=None):
|
||||
if event == 'sunrise':
|
||||
if event == SUN_EVENT_SUNRISE:
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
@@ -564,7 +565,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
def event_date(hass, event, now=None):
|
||||
if event == 'sunrise':
|
||||
if event == SUN_EVENT_SUNRISE:
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
@@ -611,7 +612,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
def event_date(hass, event, now=None):
|
||||
if event == 'sunrise':
|
||||
if event == SUN_EVENT_SUNRISE:
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
@@ -660,7 +661,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
def event_date(hass, event, now=None):
|
||||
if event == 'sunrise':
|
||||
if event == SUN_EVENT_SUNRISE:
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
@@ -720,7 +721,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
def event_date(hass, event, now=None):
|
||||
if event == 'sunrise':
|
||||
if event == SUN_EVENT_SUNRISE:
|
||||
print('sunrise {}'.format(sunrise_time))
|
||||
return sunrise_time
|
||||
print('sunset {}'.format(sunset_time))
|
||||
@@ -774,7 +775,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
def event_date(hass, event, now=None):
|
||||
if event == 'sunrise':
|
||||
if event == SUN_EVENT_SUNRISE:
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
@@ -818,7 +819,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
def event_date(hass, event, now=None):
|
||||
if event == 'sunrise':
|
||||
if event == SUN_EVENT_SUNRISE:
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
|
||||
Reference in new issue
Block a user