This commit is contained in:
Philip Lundrigan 2015-12-21 16:28:26 -07:00
parent 110d721c76
commit ff8f22854c

View File

@ -230,6 +230,36 @@ class TestAutomationSun(unittest.TestCase):
self.hass.pool.block_till_done()
self.assertEqual(0, len(self.calls))
def test_if_action_after_after(self):
self.hass.states.set(sun.ENTITY_ID, sun.STATE_ABOVE_HORIZON, {
sun.STATE_ATTR_NEXT_SETTING: '14:00:00 16-09-2015',
})
now = datetime(2015, 9, 16, 15, tzinfo=dt_util.UTC)
entity_id = 'domain.test_entity'
with patch('homeassistant.components.automation.sun.dt_util.utcnow',
return_value=now):
automation.setup(self.hass, {
automation.DOMAIN: {
'trigger': {
'platform': 'event',
'event_type': 'test_event',
},
'condition': {
'platform': 'sun',
'after': 'sunset',
},
'action': {
'service': 'test.automation'
}
}
})
self.hass.bus.fire('test_event')
self.hass.pool.block_till_done()
self.assertEqual(1, len(self.calls))
def test_if_action_before_and_after_during(self):
self.hass.states.set(sun.ENTITY_ID, sun.STATE_ABOVE_HORIZON, {
sun.STATE_ATTR_NEXT_RISING: '10:00:00 16-09-2015',