Fix homee test (#148322)

This commit is contained in:
Erik Montnemery 2025-07-07 11:59:35 +02:00 committed by GitHub
parent 42b50c71ec
commit 0c783e87d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,10 +18,18 @@ from tests.common import MockConfigEntry
@pytest.mark.parametrize(
"side_eff",
("side_eff", "config_entry_state", "active_flows"),
[
HomeeConnectionFailedException("connection timed out"),
HomeeAuthFailedException("wrong username or password"),
(
HomeeConnectionFailedException("connection timed out"),
ConfigEntryState.SETUP_RETRY,
[],
),
(
HomeeAuthFailedException("wrong username or password"),
ConfigEntryState.SETUP_ERROR,
["reauth"],
),
],
)
async def test_connection_errors(
@ -29,6 +37,8 @@ async def test_connection_errors(
mock_homee: MagicMock,
mock_config_entry: MockConfigEntry,
side_eff: Exception,
config_entry_state: ConfigEntryState,
active_flows: list[str],
) -> None:
"""Test if connection errors on startup are handled correctly."""
mock_homee.get_access_token.side_effect = side_eff
@ -36,7 +46,11 @@ async def test_connection_errors(
await hass.config_entries.async_setup(mock_config_entry.entry_id)
assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY
assert mock_config_entry.state is config_entry_state
assert [
flow["context"]["source"] for flow in hass.config_entries.flow.async_progress()
] == active_flows
async def test_connection_listener(