Ensure config entry is added to hass in reauth/reconfigure tests (#129315)
This commit is contained in:
parent
93c1245b0f
commit
2bec20ad76
2 changed files with 8 additions and 0 deletions
|
@ -1064,6 +1064,8 @@ class MockConfigEntry(config_entries.ConfigEntry):
|
|||
data: dict[str, Any] | None = None,
|
||||
) -> ConfigFlowResult:
|
||||
"""Start a reauthentication flow."""
|
||||
if self.entry_id not in hass.config_entries._entries:
|
||||
raise ValueError("Config entry must be added to hass to start reauth flow")
|
||||
return await start_reauth_flow(hass, self, context, data)
|
||||
|
||||
async def start_reconfigure_flow(
|
||||
|
@ -1073,6 +1075,10 @@ class MockConfigEntry(config_entries.ConfigEntry):
|
|||
show_advanced_options: bool = False,
|
||||
) -> ConfigFlowResult:
|
||||
"""Start a reconfiguration flow."""
|
||||
if self.entry_id not in hass.config_entries._entries:
|
||||
raise ValueError(
|
||||
"Config entry must be added to hass to start reconfiguration flow"
|
||||
)
|
||||
return await hass.config_entries.flow.async_init(
|
||||
self.domain,
|
||||
context={
|
||||
|
|
|
@ -57,6 +57,7 @@ async def test_reauth_authorization_error(
|
|||
mock_devops_client: AsyncMock,
|
||||
) -> None:
|
||||
"""Test we show user form on Azure DevOps authorization error."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
mock_devops_client.authorize.return_value = False
|
||||
mock_devops_client.authorized = False
|
||||
|
||||
|
@ -108,6 +109,7 @@ async def test_reauth_connection_error(
|
|||
mock_devops_client: AsyncMock,
|
||||
) -> None:
|
||||
"""Test we show user form on Azure DevOps connection error."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
mock_devops_client.authorize.side_effect = aiohttp.ClientError
|
||||
mock_devops_client.authorized = False
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue