mirror of
https://github.com/home-assistant/core.git
synced 2025-11-12 20:40:18 +00:00
Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
committed by
GitHub
parent
27219b6962
commit
6bb4e7d62c
@@ -473,10 +473,13 @@ async def test_raises_when_db_upgrade_in_progress(
|
||||
"""Test an exception is raised when the database migration is in progress."""
|
||||
await async_setup_component(hass, "homeassistant", {})
|
||||
|
||||
with pytest.raises(HomeAssistantError), patch(
|
||||
"homeassistant.helpers.recorder.async_migration_in_progress",
|
||||
return_value=True,
|
||||
) as mock_async_migration_in_progress:
|
||||
with (
|
||||
pytest.raises(HomeAssistantError),
|
||||
patch(
|
||||
"homeassistant.helpers.recorder.async_migration_in_progress",
|
||||
return_value=True,
|
||||
) as mock_async_migration_in_progress,
|
||||
):
|
||||
await hass.services.async_call(
|
||||
"homeassistant",
|
||||
service,
|
||||
@@ -488,11 +491,12 @@ async def test_raises_when_db_upgrade_in_progress(
|
||||
assert mock_async_migration_in_progress.called
|
||||
caplog.clear()
|
||||
|
||||
with patch(
|
||||
"homeassistant.helpers.recorder.async_migration_in_progress",
|
||||
return_value=False,
|
||||
) as mock_async_migration_in_progress, patch(
|
||||
"homeassistant.config.async_check_ha_config_file", return_value=None
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.helpers.recorder.async_migration_in_progress",
|
||||
return_value=False,
|
||||
) as mock_async_migration_in_progress,
|
||||
patch("homeassistant.config.async_check_ha_config_file", return_value=None),
|
||||
):
|
||||
await hass.services.async_call(
|
||||
"homeassistant",
|
||||
@@ -511,12 +515,16 @@ async def test_raises_when_config_is_invalid(
|
||||
"""Test an exception is raised when the configuration is invalid."""
|
||||
await async_setup_component(hass, "homeassistant", {})
|
||||
|
||||
with pytest.raises(HomeAssistantError), patch(
|
||||
"homeassistant.helpers.recorder.async_migration_in_progress",
|
||||
return_value=False,
|
||||
), patch(
|
||||
"homeassistant.config.async_check_ha_config_file", return_value=["Error 1"]
|
||||
) as mock_async_check_ha_config_file:
|
||||
with (
|
||||
pytest.raises(HomeAssistantError),
|
||||
patch(
|
||||
"homeassistant.helpers.recorder.async_migration_in_progress",
|
||||
return_value=False,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.config.async_check_ha_config_file", return_value=["Error 1"]
|
||||
) as mock_async_check_ha_config_file,
|
||||
):
|
||||
await hass.services.async_call(
|
||||
"homeassistant",
|
||||
SERVICE_HOMEASSISTANT_RESTART,
|
||||
@@ -529,12 +537,15 @@ async def test_raises_when_config_is_invalid(
|
||||
assert mock_async_check_ha_config_file.called
|
||||
caplog.clear()
|
||||
|
||||
with patch(
|
||||
"homeassistant.helpers.recorder.async_migration_in_progress",
|
||||
return_value=False,
|
||||
), patch(
|
||||
"homeassistant.config.async_check_ha_config_file", return_value=None
|
||||
) as mock_async_check_ha_config_file:
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.helpers.recorder.async_migration_in_progress",
|
||||
return_value=False,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.config.async_check_ha_config_file", return_value=None
|
||||
) as mock_async_check_ha_config_file,
|
||||
):
|
||||
await hass.services.async_call(
|
||||
"homeassistant",
|
||||
SERVICE_HOMEASSISTANT_RESTART,
|
||||
@@ -553,13 +564,15 @@ async def test_restart_homeassistant(
|
||||
) -> 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:
|
||||
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,
|
||||
@@ -575,11 +588,14 @@ async def test_restart_homeassistant(
|
||||
async def test_stop_homeassistant(hass: HomeAssistant) -> None:
|
||||
"""Test we can stop when there is a 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.core.HomeAssistant.async_stop", return_value=None
|
||||
) as mock_restart:
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.config.async_check_ha_config_file", return_value=None
|
||||
) as mock_check,
|
||||
patch(
|
||||
"homeassistant.core.HomeAssistant.async_stop", return_value=None
|
||||
) as mock_restart,
|
||||
):
|
||||
await hass.services.async_call(
|
||||
"homeassistant",
|
||||
SERVICE_HOMEASSISTANT_STOP,
|
||||
@@ -651,16 +667,19 @@ async def test_reload_all(
|
||||
assert len(core_config) == 1
|
||||
assert len(themes) == 1
|
||||
|
||||
with pytest.raises(
|
||||
HomeAssistantError,
|
||||
match=(
|
||||
"Cannot quick reload all YAML configurations because the configuration is "
|
||||
"not valid: Oh no, drama!"
|
||||
with (
|
||||
pytest.raises(
|
||||
HomeAssistantError,
|
||||
match=(
|
||||
"Cannot quick reload all YAML configurations because the configuration is "
|
||||
"not valid: Oh no, drama!"
|
||||
),
|
||||
),
|
||||
), patch(
|
||||
"homeassistant.config.async_check_ha_config_file",
|
||||
return_value="Oh no, drama!",
|
||||
) as mock_async_check_ha_config_file:
|
||||
patch(
|
||||
"homeassistant.config.async_check_ha_config_file",
|
||||
return_value="Oh no, drama!",
|
||||
) as mock_async_check_ha_config_file,
|
||||
):
|
||||
await hass.services.async_call(
|
||||
"homeassistant",
|
||||
SERVICE_RELOAD_ALL,
|
||||
|
||||
Reference in New Issue
Block a user