Add test
This commit is contained in:
parent
110d721c76
commit
ff8f22854c
1 changed files with 30 additions and 0 deletions
|
@ -230,6 +230,36 @@ class TestAutomationSun(unittest.TestCase):
|
||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
self.assertEqual(0, len(self.calls))
|
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):
|
def test_if_action_before_and_after_during(self):
|
||||||
self.hass.states.set(sun.ENTITY_ID, sun.STATE_ABOVE_HORIZON, {
|
self.hass.states.set(sun.ENTITY_ID, sun.STATE_ABOVE_HORIZON, {
|
||||||
sun.STATE_ATTR_NEXT_RISING: '10:00:00 16-09-2015',
|
sun.STATE_ATTR_NEXT_RISING: '10:00:00 16-09-2015',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue