mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Fixes bug in time trigger and adds test for ex. /two
This commit is contained in:
parent
6f1f8ffea0
commit
33b0f4d05d
@ -45,7 +45,7 @@ def trigger(hass, config, action):
|
||||
and not convert(seconds.lstrip('/'), int) % 60 == 0:
|
||||
_LOGGER.warning('Periodic seconds should be divisible with 60'
|
||||
'there will be an offset every minute')
|
||||
if isinstance(minutes, str) and hours.startswith('/') \
|
||||
if isinstance(hours, str) and hours.startswith('/') \
|
||||
and not convert(hours.lstrip('/'), int) % 24 == 0:
|
||||
_LOGGER.warning('Periodic hours should be divisible with 24'
|
||||
'there will be an offset every midnight')
|
||||
|
@ -215,4 +215,5 @@ def _matcher(subject, pattern):
|
||||
return subject % float(pattern[0].lstrip('/')) == 0
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
return MATCH_ALL == pattern or subject in pattern
|
||||
|
@ -299,3 +299,13 @@ class TestEventHelpers(unittest.TestCase):
|
||||
self._send_time_changed(datetime(2016, 5, 2, 0, 0, 0))
|
||||
self.hass.pool.block_till_done()
|
||||
self.assertEqual(2, len(specific_runs))
|
||||
|
||||
def test_periodic_task_wrong_input(self):
|
||||
specific_runs = []
|
||||
|
||||
track_utc_time_change(
|
||||
self.hass, lambda x: specific_runs.append(1), year='/two')
|
||||
|
||||
self._send_time_changed(datetime(2014, 5, 2, 0, 0, 0))
|
||||
self.hass.pool.block_till_done()
|
||||
self.assertEqual(1, len(specific_runs))
|
||||
|
Loading…
x
Reference in New Issue
Block a user