Add config reloaded events for automation and scene (#34664)
This commit is contained in:
1 parent
07469127ce
commit
1883b1d2a2
4 files changed
+22
-1
No files matched your search
@@ -4,7 +4,7 @@ from datetime import timedelta
|
||||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.automation import DOMAIN
|
||||
from homeassistant.components.automation import DOMAIN, EVENT_AUTOMATION_RELOADED
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
ATTR_NAME,
|
||||
@@ -483,6 +483,11 @@ async def test_reload_config_service(hass, calls, hass_admin_user, hass_read_onl
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data.get("event") == "test_event"
|
||||
|
||||
test_reload_event = []
|
||||
hass.bus.async_listen(
|
||||
EVENT_AUTOMATION_RELOADED, lambda event: test_reload_event.append(event)
|
||||
)
|
||||
|
||||
with patch(
|
||||
"homeassistant.config.load_yaml_config_file",
|
||||
autospec=True,
|
||||
@@ -505,6 +510,8 @@ async def test_reload_config_service(hass, calls, hass_admin_user, hass_read_onl
|
||||
# De-flake ?!
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(test_reload_event) == 1
|
||||
|
||||
assert hass.states.get("automation.hello") is None
|
||||
assert hass.states.get("automation.bye") is not None
|
||||
listeners = hass.bus.async_listeners()
|
||||
|
||||
@@ -3,6 +3,7 @@ import pytest
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.homeassistant import scene as ha_scene
|
||||
from homeassistant.components.homeassistant.scene import EVENT_SCENE_RELOADED
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.async_mock import patch
|
||||
@@ -13,6 +14,11 @@ async def test_reload_config_service(hass):
|
||||
"""Test the reload config service."""
|
||||
assert await async_setup_component(hass, "scene", {})
|
||||
|
||||
test_reloaded_event = []
|
||||
hass.bus.async_listen(
|
||||
EVENT_SCENE_RELOADED, lambda event: test_reloaded_event.append(event)
|
||||
)
|
||||
|
||||
with patch(
|
||||
"homeassistant.config.load_yaml_config_file",
|
||||
autospec=True,
|
||||
@@ -22,6 +28,7 @@ async def test_reload_config_service(hass):
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get("scene.hallo") is not None
|
||||
assert len(test_reloaded_event) == 1
|
||||
|
||||
with patch(
|
||||
"homeassistant.config.load_yaml_config_file",
|
||||
@@ -31,6 +38,7 @@ async def test_reload_config_service(hass):
|
||||
await hass.services.async_call("scene", "reload", blocking=True)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(test_reloaded_event) == 2
|
||||
assert hass.states.get("scene.hallo") is None
|
||||
assert hass.states.get("scene.bye") is not None
|
||||
|
||||
|
||||
Reference in new issue
Block a user