Fix integrations

This commit is contained in:
G Johansson
2026-09-02 15:05:41 +00:00
parent 7e39b70481
commit 5bbf7e6bbf
4 changed files with 18 additions and 12 deletions
@@ -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
+1 -1
View File
@@ -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
@@ -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(
+2 -2
View File
@@ -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(