Add support for remove services / Reload script support (#6441)

* Add support for remove services / Reload script support

* Reload support for scripts

* Add more unittest for services

* Add unittest for script reload

* Address paulus comments
This commit is contained in:
Pascal Vizeli 2017-03-08 07:51:34 +01:00 committed by Paulus Schoutsen
parent e7f442d66b
commit c937a7bcb0
7 changed files with 197 additions and 35 deletions

View file

@ -1,6 +1,7 @@
"""The tests for the Script component."""
# pylint: disable=protected-access
import unittest
from unittest.mock import patch
from homeassistant.core import callback
from homeassistant.setup import setup_component
@ -172,3 +173,38 @@ class TestScriptComponent(unittest.TestCase):
assert len(calls) == 2
assert calls[-1].data['hello'] == 'universe'
def test_reload_service(self):
"""Verify that the turn_on service."""
assert setup_component(self.hass, 'script', {
'script': {
'test': {
'sequence': [{
'delay': {
'seconds': 5
}
}]
}
}
})
assert self.hass.states.get(ENTITY_ID) is not None
assert self.hass.services.has_service(script.DOMAIN, 'test')
with patch('homeassistant.config.load_yaml_config_file', return_value={
'script': {
'test2': {
'sequence': [{
'delay': {
'seconds': 5
}
}]
}}}):
script.reload(self.hass)
self.hass.block_till_done()
assert self.hass.states.get(ENTITY_ID) is None
assert not self.hass.services.has_service(script.DOMAIN, 'test')
assert self.hass.states.get("script.test2") is not None
assert self.hass.services.has_service(script.DOMAIN, 'test2')