Tests for time and a fix for wrong access of _LOGGER

pull/1002/head
magnusknutas 2016-01-26 21:11:30 +01:00
parent 2382dffbf4
commit d4b444823c
2 changed files with 58 additions and 1 deletions

View File

@ -71,7 +71,7 @@ def if_action(hass, config):
weekday = config.get(CONF_WEEKDAY)
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",
CONF_BEFORE, CONF_AFTER, CONF_WEEKDAY)
return None

View File

@ -301,6 +301,63 @@ class TestAutomationTime(unittest.TestCase):
self.hass.pool.block_till_done()
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):
self.assertTrue(automation.setup(self.hass, {
automation.DOMAIN: {