From 5bbf7e6bbfdadb0eb3a68a3f29d9b2c68be58762 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Thu, 2 Jul 2026 14:41:34 +0000 Subject: [PATCH] Fix integrations --- homeassistant/components/intellifire/__init__.py | 8 ++++++-- tests/components/teslemetry/test_init.py | 2 +- tests/components/trafikverket_train/test_init.py | 16 +++++++++------- tests/components/xbox/test_config_flow.py | 4 ++-- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/intellifire/__init__.py b/homeassistant/components/intellifire/__init__.py index 8bc8f9921aef..1f3c021744aa 100644 --- a/homeassistant/components/intellifire/__init__.py +++ b/homeassistant/components/intellifire/__init__.py @@ -17,7 +17,11 @@ from homeassistant.const import ( Platform, ) from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady +from homeassistant.exceptions import ( + ConfigEntryAuthFailed, + ConfigEntryNotReady, + HomeAssistantError, +) from .const import ( API_MODE_LOCAL, @@ -89,7 +93,7 @@ async def async_migrate_entry( new_data = cloud_interface.user_data.get_data_for_ip(new[CONF_HOST]) if not new_data: - raise ConfigEntryAuthFailed + raise HomeAssistantError new[CONF_API_KEY] = new_data.api_key new[CONF_WEB_CLIENT_ID] = new_data.web_client_id new[CONF_AUTH_COOKIE] = new_data.auth_cookie diff --git a/tests/components/teslemetry/test_init.py b/tests/components/teslemetry/test_init.py index c0f84c4dd3ab..b5cbd8984784 100644 --- a/tests/components/teslemetry/test_init.py +++ b/tests/components/teslemetry/test_init.py @@ -448,7 +448,7 @@ async def test_migrate_from_version_1_token_endpoint_error(hass: HomeAssistant) entry = hass.config_entries.async_get_entry(mock_entry.entry_id) assert entry is not None - assert entry.state is ConfigEntryState.MIGRATION_ERROR + assert entry.state is ConfigEntryState.SETUP_ERROR assert entry.version == 1 # Version should remain unchanged on migration failure diff --git a/tests/components/trafikverket_train/test_init.py b/tests/components/trafikverket_train/test_init.py index 01df70bcd787..f7d7bfcf7173 100644 --- a/tests/components/trafikverket_train/test_init.py +++ b/tests/components/trafikverket_train/test_init.py @@ -233,15 +233,17 @@ async def test_migrate_entry_from_future_version_fails( @pytest.mark.parametrize( - ("side_effect"), + ("side_effect", "state"), [ - (InvalidAuthentication), - (NoTrainStationFound), - (UnknownError), - (Exception), + (InvalidAuthentication, ConfigEntryState.SETUP_ERROR), + (NoTrainStationFound, ConfigEntryState.MIGRATION_ERROR), + (UnknownError, ConfigEntryState.MIGRATION_ERROR), + (Exception, ConfigEntryState.MIGRATION_ERROR), ], ) -async def test_migrate_entry_fails(hass: HomeAssistant, side_effect: Exception) -> None: +async def test_migrate_entry_fails( + hass: HomeAssistant, side_effect: Exception, state: ConfigEntryState +) -> None: """Test migrate entry fails.""" entry = MockConfigEntry( domain=DOMAIN, @@ -263,7 +265,7 @@ async def test_migrate_entry_fails(hass: HomeAssistant, side_effect: Exception) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state is ConfigEntryState.MIGRATION_ERROR + assert entry.state is state async def test_migrate_entry_fails_multiple_stations( diff --git a/tests/components/xbox/test_config_flow.py b/tests/components/xbox/test_config_flow.py index c80c8c509fe7..7b8d3ccac8cc 100644 --- a/tests/components/xbox/test_config_flow.py +++ b/tests/components/xbox/test_config_flow.py @@ -698,7 +698,7 @@ async def test_migration_exceptions( await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state is config_entries.ConfigEntryState.MIGRATION_ERROR + assert config_entry.state is config_entries.ConfigEntryState.SETUP_RETRY @pytest.mark.usefixtures("xbox_live_client", "authentication_manager") @@ -733,7 +733,7 @@ async def test_migration_implementation_unavailable(hass: HomeAssistant) -> None await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state is config_entries.ConfigEntryState.MIGRATION_ERROR + assert config_entry.state is config_entries.ConfigEntryState.SETUP_RETRY @pytest.mark.usefixtures(