mirror of
https://github.com/home-assistant/core.git
synced 2026-11-06 05:32:45 -04:00
Fix race in starting reauth flows (#103130)
This commit is contained in:
@@ -42,6 +42,7 @@ async def test_setup_auth_failed(
|
||||
config_entry.add_to_hass(hass)
|
||||
with patch.object(hass.config_entries.flow, "async_init") as mock_flow_init:
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert config_entry.state is ConfigEntryState.SETUP_ERROR
|
||||
mock_flow_init.assert_called_with(
|
||||
DOMAIN,
|
||||
|
||||
@@ -3791,6 +3791,20 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.config_entries.flow.async_progress()) == 2
|
||||
|
||||
# Abort all existing flows
|
||||
for flow in hass.config_entries.flow.async_progress():
|
||||
hass.config_entries.flow.async_abort(flow["flow_id"])
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Check that we can't start duplicate reauth flows
|
||||
# without blocking between flows
|
||||
entry.async_start_reauth(hass, {"extra_context": "some_extra_context"})
|
||||
entry.async_start_reauth(hass, {"extra_context": "some_extra_context"})
|
||||
entry.async_start_reauth(hass, {"extra_context": "some_extra_context"})
|
||||
entry.async_start_reauth(hass, {"extra_context": "some_extra_context"})
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.config_entries.flow.async_progress()) == 1
|
||||
|
||||
|
||||
async def test_get_active_flows(hass: HomeAssistant) -> None:
|
||||
"""Test the async_get_active_flows helper."""
|
||||
|
||||
Reference in New Issue
Block a user