mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Tests for time and a fix for wrong access of _LOGGER
This commit is contained in:
parent
2382dffbf4
commit
d4b444823c
@ -71,7 +71,7 @@ def if_action(hass, config):
|
|||||||
weekday = config.get(CONF_WEEKDAY)
|
weekday = config.get(CONF_WEEKDAY)
|
||||||
|
|
||||||
if before is None and after is None and weekday is None:
|
if before is None and after is None and weekday is None:
|
||||||
logging.getLogger(__name__).error(
|
_LOGGER.error(
|
||||||
"Missing if-condition configuration key %s, %s or %s",
|
"Missing if-condition configuration key %s, %s or %s",
|
||||||
CONF_BEFORE, CONF_AFTER, CONF_WEEKDAY)
|
CONF_BEFORE, CONF_AFTER, CONF_WEEKDAY)
|
||||||
return None
|
return None
|
||||||
|
@ -301,6 +301,63 @@ class TestAutomationTime(unittest.TestCase):
|
|||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
self.assertEqual(1, len(self.calls))
|
self.assertEqual(1, len(self.calls))
|
||||||
|
|
||||||
|
def test_if_fires_periodic_seconds(self):
|
||||||
|
self.assertTrue(automation.setup(self.hass, {
|
||||||
|
automation.DOMAIN: {
|
||||||
|
'trigger': {
|
||||||
|
'platform': 'time',
|
||||||
|
'seconds': "/2",
|
||||||
|
},
|
||||||
|
'action': {
|
||||||
|
'service': 'test.automation'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
fire_time_changed(self.hass, dt_util.utcnow().replace(
|
||||||
|
hour=0, minute=0, second=2))
|
||||||
|
|
||||||
|
self.hass.pool.block_till_done()
|
||||||
|
self.assertEqual(1, len(self.calls))
|
||||||
|
|
||||||
|
def test_if_fires_periodic_minutes(self):
|
||||||
|
self.assertTrue(automation.setup(self.hass, {
|
||||||
|
automation.DOMAIN: {
|
||||||
|
'trigger': {
|
||||||
|
'platform': 'time',
|
||||||
|
'minutes': "/2",
|
||||||
|
},
|
||||||
|
'action': {
|
||||||
|
'service': 'test.automation'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
fire_time_changed(self.hass, dt_util.utcnow().replace(
|
||||||
|
hour=0, minute=2, second=0))
|
||||||
|
|
||||||
|
self.hass.pool.block_till_done()
|
||||||
|
self.assertEqual(1, len(self.calls))
|
||||||
|
|
||||||
|
def test_if_fires_periodic_hours(self):
|
||||||
|
self.assertTrue(automation.setup(self.hass, {
|
||||||
|
automation.DOMAIN: {
|
||||||
|
'trigger': {
|
||||||
|
'platform': 'time',
|
||||||
|
'hours': "/2",
|
||||||
|
},
|
||||||
|
'action': {
|
||||||
|
'service': 'test.automation'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
fire_time_changed(self.hass, dt_util.utcnow().replace(
|
||||||
|
hour=2, minute=0, second=0))
|
||||||
|
|
||||||
|
self.hass.pool.block_till_done()
|
||||||
|
self.assertEqual(1, len(self.calls))
|
||||||
|
|
||||||
def test_if_fires_using_after(self):
|
def test_if_fires_using_after(self):
|
||||||
self.assertTrue(automation.setup(self.hass, {
|
self.assertTrue(automation.setup(self.hass, {
|
||||||
automation.DOMAIN: {
|
automation.DOMAIN: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user