mirror of
https://github.com/home-assistant/core.git
synced 2025-11-16 22:40:44 +00:00
Make it possible to restart core in safe mode (#102606)
This commit is contained in:
@@ -11,6 +11,7 @@ from homeassistant import config
|
||||
import homeassistant.components as comps
|
||||
from homeassistant.components.homeassistant import (
|
||||
ATTR_ENTRY_ID,
|
||||
ATTR_SAFE_MODE,
|
||||
SERVICE_CHECK_CONFIG,
|
||||
SERVICE_HOMEASSISTANT_RESTART,
|
||||
SERVICE_HOMEASSISTANT_STOP,
|
||||
@@ -536,22 +537,32 @@ async def test_raises_when_config_is_invalid(
|
||||
assert mock_async_check_ha_config_file.called
|
||||
|
||||
|
||||
async def test_restart_homeassistant(hass: HomeAssistant) -> None:
|
||||
@pytest.mark.parametrize(
|
||||
("service_data", "safe_mode_enabled"),
|
||||
[({}, False), ({ATTR_SAFE_MODE: False}, False), ({ATTR_SAFE_MODE: True}, True)],
|
||||
)
|
||||
async def test_restart_homeassistant(
|
||||
hass: HomeAssistant, service_data: dict, safe_mode_enabled: bool
|
||||
) -> None:
|
||||
"""Test we can restart when there is no configuration error."""
|
||||
await async_setup_component(hass, "homeassistant", {})
|
||||
with patch(
|
||||
"homeassistant.config.async_check_ha_config_file", return_value=None
|
||||
) as mock_check, patch(
|
||||
"homeassistant.config.async_enable_safe_mode"
|
||||
) as mock_safe_mode, patch(
|
||||
"homeassistant.core.HomeAssistant.async_stop", return_value=None
|
||||
) as mock_restart:
|
||||
await hass.services.async_call(
|
||||
"homeassistant",
|
||||
SERVICE_HOMEASSISTANT_RESTART,
|
||||
service_data,
|
||||
blocking=True,
|
||||
)
|
||||
assert mock_check.called
|
||||
await hass.async_block_till_done()
|
||||
assert mock_restart.called
|
||||
assert mock_safe_mode.called == safe_mode_enabled
|
||||
|
||||
|
||||
async def test_stop_homeassistant(hass: HomeAssistant) -> None:
|
||||
|
||||
Reference in New Issue
Block a user