mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 18:28:14 +02:00
Fix mqtt is not reloading without yaml config (#103159)
This commit is contained in:
@ -3974,3 +3974,39 @@ async def test_reload_with_invalid_config(
|
||||
|
||||
# Test nothing changed as loading the config failed
|
||||
assert hass.states.get("sensor.test") is not None
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"hass_config",
|
||||
[
|
||||
{
|
||||
"mqtt": [
|
||||
{
|
||||
"sensor": {
|
||||
"name": "test",
|
||||
"state_topic": "test-topic",
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
],
|
||||
)
|
||||
async def test_reload_with_empty_config(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
) -> None:
|
||||
"""Test reloading yaml config fails."""
|
||||
await mqtt_mock_entry()
|
||||
assert hass.states.get("sensor.test") is not None
|
||||
|
||||
# Reload with an empty config and assert again
|
||||
with patch("homeassistant.config.load_yaml_config_file", return_value={}):
|
||||
await hass.services.async_call(
|
||||
"mqtt",
|
||||
SERVICE_RELOAD,
|
||||
{},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get("sensor.test") is None
|
||||
|
Reference in New Issue
Block a user