diff --git a/tests/common.py b/tests/common.py index ad14481e385..8bd45e4d7f8 100644 --- a/tests/common.py +++ b/tests/common.py @@ -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={ diff --git a/tests/components/azure_devops/test_config_flow.py b/tests/components/azure_devops/test_config_flow.py index 577067d5744..64c771a7adc 100644 --- a/tests/components/azure_devops/test_config_flow.py +++ b/tests/components/azure_devops/test_config_flow.py @@ -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