Rename safe mode to recovery mode (#102580)

This commit is contained in:
Erik Montnemery
2023-10-23 20:33:08 +02:00
committed by GitHub
parent 7a009ed6cd
commit c481fdb7d0
17 changed files with 67 additions and 65 deletions
+4 -4
View File
@@ -177,14 +177,14 @@ async def test_themes_api(hass: HomeAssistant, themes_ws_client) -> None:
assert msg["result"]["default_dark_theme"] is None
assert msg["result"]["themes"] == MOCK_THEMES
# safe mode
hass.config.safe_mode = True
# recovery mode
hass.config.recovery_mode = True
await themes_ws_client.send_json({"id": 6, "type": "frontend/get_themes"})
msg = await themes_ws_client.receive_json()
assert msg["result"]["default_theme"] == "safe_mode"
assert msg["result"]["default_theme"] == "recovery_mode"
assert msg["result"]["themes"] == {
"safe_mode": {"primary-color": "#db4437", "accent-color": "#ffca28"}
"recovery_mode": {"primary-color": "#db4437", "accent-color": "#ffca28"}
}
+8 -8
View File
@@ -289,7 +289,7 @@ async def test_emergency_ssl_certificate_when_invalid(
_setup_broken_ssl_pem_files, tmp_path
)
hass.config.safe_mode = True
hass.config.recovery_mode = True
assert (
await async_setup_component(
hass,
@@ -304,17 +304,17 @@ async def test_emergency_ssl_certificate_when_invalid(
await hass.async_start()
await hass.async_block_till_done()
assert (
"Home Assistant is running in safe mode with an emergency self signed ssl certificate because the configured SSL certificate was not usable"
"Home Assistant is running in recovery mode with an emergency self signed ssl certificate because the configured SSL certificate was not usable"
in caplog.text
)
assert hass.http.site is not None
async def test_emergency_ssl_certificate_not_used_when_not_safe_mode(
async def test_emergency_ssl_certificate_not_used_when_not_recovery_mode(
hass: HomeAssistant, tmp_path: Path, caplog: pytest.LogCaptureFixture
) -> None:
"""Test an emergency cert is only used in safe mode."""
"""Test an emergency cert is only used in recovery mode."""
cert_path, key_path = await hass.async_add_executor_job(
_setup_broken_ssl_pem_files, tmp_path
@@ -338,7 +338,7 @@ async def test_emergency_ssl_certificate_when_invalid_get_url_fails(
cert_path, key_path = await hass.async_add_executor_job(
_setup_broken_ssl_pem_files, tmp_path
)
hass.config.safe_mode = True
hass.config.recovery_mode = True
with patch(
"homeassistant.components.http.get_url", side_effect=NoURLAvailableError
@@ -358,7 +358,7 @@ async def test_emergency_ssl_certificate_when_invalid_get_url_fails(
assert len(mock_get_url.mock_calls) == 1
assert (
"Home Assistant is running in safe mode with an emergency self signed ssl certificate because the configured SSL certificate was not usable"
"Home Assistant is running in recovery mode with an emergency self signed ssl certificate because the configured SSL certificate was not usable"
in caplog.text
)
@@ -373,7 +373,7 @@ async def test_invalid_ssl_and_cannot_create_emergency_cert(
cert_path, key_path = await hass.async_add_executor_job(
_setup_broken_ssl_pem_files, tmp_path
)
hass.config.safe_mode = True
hass.config.recovery_mode = True
with patch(
"homeassistant.components.http.x509.CertificateBuilder", side_effect=OSError
@@ -410,7 +410,7 @@ async def test_invalid_ssl_and_cannot_create_emergency_cert_with_ssl_peer_cert(
cert_path, key_path = await hass.async_add_executor_job(
_setup_broken_ssl_pem_files, tmp_path
)
hass.config.safe_mode = True
hass.config.recovery_mode = True
with patch(
"homeassistant.components.http.x509.CertificateBuilder", side_effect=OSError
+2 -2
View File
@@ -48,8 +48,8 @@ async def test_lovelace_from_storage(
assert response["result"] == {"yo": "hello"}
# Test with safe mode
hass.config.safe_mode = True
# Test with recovery mode
hass.config.recovery_mode = True
await client.send_json({"id": 8, "type": "lovelace/config"})
response = await client.receive_json()
assert not response["success"]
+6 -6
View File
@@ -112,11 +112,11 @@ async def test_component_requirement_not_found(hass: HomeAssistant) -> None:
assert not res.errors
async def test_component_not_found_safe_mode(hass: HomeAssistant) -> None:
"""Test no errors if component not found in safe mode."""
async def test_component_not_found_recovery_mode(hass: HomeAssistant) -> None:
"""Test no errors if component not found in recovery mode."""
# Make sure they don't exist
files = {YAML_CONFIG_FILE: BASE_CONFIG + "beer:"}
hass.config.safe_mode = True
hass.config.recovery_mode = True
with patch("os.path.isfile", return_value=True), patch_yaml_files(files):
res = await async_check_ha_config_file(hass)
log_ha_config(res)
@@ -145,11 +145,11 @@ async def test_component_platform_not_found_2(hass: HomeAssistant) -> None:
assert not res.errors
async def test_platform_not_found_safe_mode(hass: HomeAssistant) -> None:
"""Test no errors if platform not found in safe_mode."""
async def test_platform_not_found_recovery_mode(hass: HomeAssistant) -> None:
"""Test no errors if platform not found in recovery_mode."""
# Make sure they don't exist
files = {YAML_CONFIG_FILE: BASE_CONFIG + "light:\n platform: beer"}
hass.config.safe_mode = True
hass.config.recovery_mode = True
with patch("os.path.isfile", return_value=True), patch_yaml_files(files):
res = await async_check_ha_config_file(hass)
log_ha_config(res)
+7 -7
View File
@@ -488,7 +488,7 @@ async def test_setup_hass(
log_file=log_file,
log_no_color=log_no_color,
skip_pip=True,
safe_mode=False,
recovery_mode=False,
),
)
@@ -547,7 +547,7 @@ async def test_setup_hass_takes_longer_than_log_slow_startup(
log_file=log_file,
log_no_color=log_no_color,
skip_pip=True,
safe_mode=False,
recovery_mode=False,
),
)
@@ -574,7 +574,7 @@ async def test_setup_hass_invalid_yaml(
log_file="",
log_no_color=False,
skip_pip=True,
safe_mode=False,
recovery_mode=False,
),
)
@@ -602,7 +602,7 @@ async def test_setup_hass_config_dir_nonexistent(
log_file="",
log_no_color=False,
skip_pip=True,
safe_mode=False,
recovery_mode=False,
),
)
is None
@@ -630,7 +630,7 @@ async def test_setup_hass_safe_mode(
log_file="",
log_no_color=False,
skip_pip=True,
safe_mode=True,
recovery_mode=True,
),
)
@@ -661,7 +661,7 @@ async def test_setup_hass_invalid_core_config(
log_file="",
log_no_color=False,
skip_pip=True,
safe_mode=False,
recovery_mode=False,
),
)
@@ -704,7 +704,7 @@ async def test_setup_safe_mode_if_no_frontend(
log_file=log_file,
log_no_color=log_no_color,
skip_pip=True,
safe_mode=False,
recovery_mode=False,
),
)
+2 -2
View File
@@ -1449,7 +1449,7 @@ async def test_config_defaults() -> None:
assert config.allowlist_external_dirs == set()
assert config.allowlist_external_urls == set()
assert config.media_dirs == {}
assert config.safe_mode is False
assert config.recovery_mode is False
assert config.legacy_templates is False
assert config.currency == "EUR"
assert config.country is None
@@ -1487,7 +1487,7 @@ async def test_config_as_dict() -> None:
"allowlist_external_urls": set(),
"version": __version__,
"config_source": ha.ConfigSource.DEFAULT,
"safe_mode": False,
"recovery_mode": False,
"state": "RUNNING",
"external_url": None,
"internal_url": None,
+3 -3
View File
@@ -690,9 +690,9 @@ async def test_get_mqtt(hass: HomeAssistant) -> None:
assert mqtt["test_2"] == ["test_2/discovery"]
async def test_get_custom_components_safe_mode(hass: HomeAssistant) -> None:
"""Test that we get empty custom components in safe mode."""
hass.config.safe_mode = True
async def test_get_custom_components_recovery_mode(hass: HomeAssistant) -> None:
"""Test that we get empty custom components in recovery mode."""
hass.config.recovery_mode = True
assert await loader.async_get_custom_components(hass) == {}