mirror of
https://github.com/home-assistant/core.git
synced 2026-12-05 05:14:01 -04:00
Fix rest_command reload when the rest_command key is removed (#187262)
This commit is contained in:
@@ -99,7 +99,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
continue
|
||||
hass.services.async_remove(DOMAIN, existing_service)
|
||||
|
||||
for name, command_config in conf[DOMAIN].items():
|
||||
for name, command_config in conf.get(DOMAIN, {}).items():
|
||||
async_register_rest_command(name, command_config)
|
||||
|
||||
@callback
|
||||
|
||||
@@ -48,6 +48,25 @@ async def test_reload(hass: HomeAssistant, setup_component: ComponentSetup) -> N
|
||||
assert not hass.services.has_service(DOMAIN, "get_test")
|
||||
|
||||
|
||||
async def test_reload_without_domain_config(
|
||||
hass: HomeAssistant, setup_component: ComponentSetup
|
||||
) -> None:
|
||||
"""Verify reload removes all commands when the domain key is gone."""
|
||||
await setup_component()
|
||||
|
||||
assert hass.services.has_service(DOMAIN, "get_test")
|
||||
|
||||
with patch(
|
||||
"homeassistant.config.load_yaml_config_file",
|
||||
autospec=True,
|
||||
return_value={},
|
||||
):
|
||||
await hass.services.async_call(DOMAIN, SERVICE_RELOAD, blocking=True)
|
||||
|
||||
assert not hass.services.has_service(DOMAIN, "get_test")
|
||||
assert hass.services.has_service(DOMAIN, SERVICE_RELOAD)
|
||||
|
||||
|
||||
async def test_setup_tests(
|
||||
hass: HomeAssistant, setup_component: ComponentSetup
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user