Skip to content

Commit

Permalink
Rename the safe_mode integration to recovery_mode (home-assistant#102581
Browse files Browse the repository at this point in the history
)

* Rename safe mode integration to recovery mode

* Update code
  • Loading branch information
emontnemery authored Oct 24, 2023
1 parent 6372bc3 commit b953f29
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .core_files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ components: &components
- homeassistant/components/persistent_notification/**
- homeassistant/components/person/**
- homeassistant/components/recorder/**
- homeassistant/components/recovery_mode/**
- homeassistant/components/repairs/**
- homeassistant/components/safe_mode/**
- homeassistant/components/script/**
- homeassistant/components/shopping_list/**
- homeassistant/components/ssdp/**
Expand Down
4 changes: 2 additions & 2 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,8 @@ build.json @home-assistant/supervisor
/tests/components/recollect_waste/ @bachya
/homeassistant/components/recorder/ @home-assistant/core
/tests/components/recorder/ @home-assistant/core
/homeassistant/components/recovery_mode/ @home-assistant/core
/tests/components/recovery_mode/ @home-assistant/core
/homeassistant/components/rejseplanen/ @DarkFox
/homeassistant/components/remote/ @home-assistant/core
/tests/components/remote/ @home-assistant/core
Expand Down Expand Up @@ -1085,8 +1087,6 @@ build.json @home-assistant/supervisor
/tests/components/rympro/ @OnFreund @elad-bar @maorcc
/homeassistant/components/sabnzbd/ @shaiu
/tests/components/sabnzbd/ @shaiu
/homeassistant/components/safe_mode/ @home-assistant/core
/tests/components/safe_mode/ @home-assistant/core
/homeassistant/components/saj/ @fredericvl
/homeassistant/components/samsungtv/ @chemelli74 @epenet
/tests/components/samsungtv/ @chemelli74 @epenet
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ async def async_setup_hass(
http_conf = (await http.async_get_last_config(hass)) or {}

await async_from_config_dict(
{"safe_mode": {}, "http": http_conf},
{"recovery_mode": {}, "http": http_conf},
hass,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
"""The Safe Mode integration."""
"""The Recovery Mode integration."""
from homeassistant.components import persistent_notification
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.typing import ConfigType

DOMAIN = "safe_mode"
DOMAIN = "recovery_mode"

CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)


async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Safe Mode component."""
"""Set up the Recovery Mode component."""
persistent_notification.async_create(
hass,
(
"Home Assistant is running in safe mode. Check [the error"
"Home Assistant is running in recovery mode. Check [the error"
" log](/config/logs) to see what went wrong."
),
"Safe Mode",
"Recovery Mode",
)
return True
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"domain": "safe_mode",
"name": "Safe Mode",
"domain": "recovery_mode",
"name": "Recovery Mode",
"codeowners": ["@home-assistant/core"],
"config_flow": false,
"dependencies": ["frontend", "persistent_notification", "cloud"],
"documentation": "https://www.home-assistant.io/integrations/safe_mode",
"documentation": "https://www.home-assistant.io/integrations/recovery_mode",
"integration_type": "system",
"quality_scale": "internal"
}
2 changes: 1 addition & 1 deletion script/hassfest/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class QualityScale(IntEnum):
"proxy",
"python_script",
"raspberry_pi",
"recovery_mode",
"repairs",
"safe_mode",
"schedule",
"script",
"search",
Expand Down
1 change: 1 addition & 0 deletions tests/components/recovery_mode/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Tests for the Recovery Mode integration."""
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""Tests for safe mode integration."""
"""Tests for the Recovery Mode integration."""
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component

from tests.common import async_get_persistent_notifications


async def test_works(hass: HomeAssistant) -> None:
"""Test safe mode works."""
assert await async_setup_component(hass, "safe_mode", {})
"""Test Recovery Mode works."""
assert await async_setup_component(hass, "recovery_mode", {})
await hass.async_block_till_done()
notifications = async_get_persistent_notifications(hass)
assert len(notifications) == 1
1 change: 0 additions & 1 deletion tests/components/safe_mode/__init__.py

This file was deleted.

18 changes: 9 additions & 9 deletions tests/test_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async def test_empty_setup(hass: HomeAssistant) -> None:
assert domain in hass.config.components, domain


async def test_core_failure_loads_safe_mode(
async def test_core_failure_loads_recovery_mode(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
) -> None:
"""Test failing core setup aborts further setup."""
Expand Down Expand Up @@ -495,7 +495,7 @@ async def test_setup_hass(
assert "Waiting on integrations to complete setup" not in caplog.text

assert "browser" in hass.config.components
assert "safe_mode" not in hass.config.components
assert "recovery_mode" not in hass.config.components

assert len(mock_enable_logging.mock_calls) == 1
assert mock_enable_logging.mock_calls[0][1] == (
Expand Down Expand Up @@ -578,7 +578,7 @@ async def test_setup_hass_invalid_yaml(
),
)

assert "safe_mode" in hass.config.components
assert "recovery_mode" in hass.config.components
assert len(mock_mount_local_lib_path.mock_calls) == 0


Expand Down Expand Up @@ -609,7 +609,7 @@ async def test_setup_hass_config_dir_nonexistent(
)


async def test_setup_hass_safe_mode(
async def test_setup_hass_recovery_mode(
mock_enable_logging: Mock,
mock_is_virtual_env: Mock,
mock_mount_local_lib_path: AsyncMock,
Expand All @@ -634,7 +634,7 @@ async def test_setup_hass_safe_mode(
),
)

assert "safe_mode" in hass.config.components
assert "recovery_mode" in hass.config.components
assert len(mock_mount_local_lib_path.mock_calls) == 0

# Validate we didn't try to set up config entry.
Expand Down Expand Up @@ -665,7 +665,7 @@ async def test_setup_hass_invalid_core_config(
),
)

assert "safe_mode" in hass.config.components
assert "recovery_mode" in hass.config.components


@pytest.mark.parametrize(
Expand All @@ -681,7 +681,7 @@ async def test_setup_hass_invalid_core_config(
}
],
)
async def test_setup_safe_mode_if_no_frontend(
async def test_setup_recovery_mode_if_no_frontend(
mock_hass_config: None,
mock_enable_logging: Mock,
mock_is_virtual_env: Mock,
Expand All @@ -690,7 +690,7 @@ async def test_setup_safe_mode_if_no_frontend(
mock_process_ha_config_upgrade: Mock,
event_loop: asyncio.AbstractEventLoop,
) -> None:
"""Test we setup safe mode if frontend didn't load."""
"""Test we setup recovery mode if frontend didn't load."""
verbose = Mock()
log_rotate_days = Mock()
log_file = Mock()
Expand All @@ -708,7 +708,7 @@ async def test_setup_safe_mode_if_no_frontend(
),
)

assert "safe_mode" in hass.config.components
assert "recovery_mode" in hass.config.components
assert hass.config.config_dir == get_test_config_dir()
assert hass.config.skip_pip
assert hass.config.internal_url == "http://192.168.1.100:8123"
Expand Down

0 comments on commit b953f29

Please sign in to comment.