1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-17 23:53:49 +01:00

Trigger recovery mode on registry major version downgrade (#164340)

This commit is contained in:
Artur Pragacz
2026-03-03 11:46:32 +01:00
committed by GitHub
parent f94a075641
commit 9cc4a3e427
16 changed files with 236 additions and 58 deletions

View File

@@ -965,6 +965,46 @@ async def test_setup_hass_recovery_mode_and_safe_mode(
assert "Starting in safe mode" not in caplog.text
@pytest.mark.parametrize("hass_config", [{"frontend": {}}])
@pytest.mark.usefixtures("mock_hass_config")
async def test_storage_version_too_new_triggers_recovery_mode(
hass_storage: dict[str, Any],
mock_enable_logging: AsyncMock,
mock_is_virtual_env: Mock,
mock_mount_local_lib_path: AsyncMock,
mock_ensure_config_exists: AsyncMock,
mock_process_ha_config_upgrade: Mock,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test that a storage file with a newer major version triggers recovery mode."""
hass_storage["core.entity_registry"] = {
"version": 99,
"minor_version": 1,
"key": "core.entity_registry",
"data": {},
}
hass = await bootstrap.async_setup_hass(
runner.RuntimeConfig(
config_dir=get_test_config_dir(),
verbose=False,
log_rotate_days=10,
log_file="",
log_no_color=False,
skip_pip=True,
recovery_mode=False,
),
)
assert hass is not None
assert hass.config.recovery_mode is True
assert "recovery_mode" in hass.config.components
assert (
"Storage file core.entity_registry was created"
" by a newer version of Home Assistant" in caplog.text
)
@pytest.mark.parametrize("hass_config", [{"homeassistant": {"non-existing": 1}}])
@pytest.mark.usefixtures("mock_hass_config")
async def test_setup_hass_invalid_core_config(