1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-25 05:26:47 +00:00

Make it possible to restart core in safe mode (#102606)

This commit is contained in:
Erik Montnemery
2023-10-24 14:47:58 +02:00
committed by GitHub
parent 46322a0f59
commit 97cc05d0b4
14 changed files with 170 additions and 11 deletions

View File

@@ -49,6 +49,7 @@ VERSION_PATH = os.path.join(CONFIG_DIR, config_util.VERSION_FILE)
AUTOMATIONS_PATH = os.path.join(CONFIG_DIR, config_util.AUTOMATION_CONFIG_PATH)
SCRIPTS_PATH = os.path.join(CONFIG_DIR, config_util.SCRIPT_CONFIG_PATH)
SCENES_PATH = os.path.join(CONFIG_DIR, config_util.SCENE_CONFIG_PATH)
SAFE_MODE_PATH = os.path.join(CONFIG_DIR, config_util.SAFE_MODE_FILENAME)
def create_file(path):
@@ -80,6 +81,9 @@ def teardown():
if os.path.isfile(SCENES_PATH):
os.remove(SCENES_PATH)
if os.path.isfile(SAFE_MODE_PATH):
os.remove(SAFE_MODE_PATH)
async def test_create_default_config(hass: HomeAssistant) -> None:
"""Test creation of default config."""
@@ -1386,3 +1390,12 @@ async def test_core_store_no_country(
await hass.config.async_update(**{"country": "SE"})
issue = issue_registry.async_get_issue("homeassistant", issue_id)
assert not issue
async def test_safe_mode(hass: HomeAssistant) -> None:
"""Test safe mode."""
assert config_util.safe_mode_enabled(hass.config.config_dir) is False
assert config_util.safe_mode_enabled(hass.config.config_dir) is False
await config_util.async_enable_safe_mode(hass)
assert config_util.safe_mode_enabled(hass.config.config_dir) is True
assert config_util.safe_mode_enabled(hass.config.config_dir) is False