Fix aborting flows for single config entry integrations (#129805)
parent
df35c8e707
commit
4784199038
|
@ -1457,6 +1457,7 @@ class ConfigEntriesFlowManager(
|
||||||
or progress_unique_id == DEFAULT_DISCOVERY_UNIQUE_ID
|
or progress_unique_id == DEFAULT_DISCOVERY_UNIQUE_ID
|
||||||
):
|
):
|
||||||
self.async_abort(progress_flow_id)
|
self.async_abort(progress_flow_id)
|
||||||
|
continue
|
||||||
|
|
||||||
# Abort any flows in progress for the same handler
|
# Abort any flows in progress for the same handler
|
||||||
# when integration allows only one config entry
|
# when integration allows only one config entry
|
||||||
|
|
|
@ -5843,8 +5843,20 @@ async def test_avoid_adding_second_config_entry_on_single_config_entry(
|
||||||
assert result["translation_domain"] == HOMEASSISTANT_DOMAIN
|
assert result["translation_domain"] == HOMEASSISTANT_DOMAIN
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
("flow_1_unique_id", "flow_2_unique_id"),
|
||||||
|
[
|
||||||
|
(None, None),
|
||||||
|
("very_unique", "very_unique"),
|
||||||
|
(None, config_entries.DEFAULT_DISCOVERY_UNIQUE_ID),
|
||||||
|
("very_unique", config_entries.DEFAULT_DISCOVERY_UNIQUE_ID),
|
||||||
|
],
|
||||||
|
)
|
||||||
async def test_in_progress_get_canceled_when_entry_is_created(
|
async def test_in_progress_get_canceled_when_entry_is_created(
|
||||||
hass: HomeAssistant, manager: config_entries.ConfigEntries
|
hass: HomeAssistant,
|
||||||
|
manager: config_entries.ConfigEntries,
|
||||||
|
flow_1_unique_id: str | None,
|
||||||
|
flow_2_unique_id: str | None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that we abort all in progress flows when a new entry is created on a single instance only integration."""
|
"""Test that we abort all in progress flows when a new entry is created on a single instance only integration."""
|
||||||
integration = loader.Integration(
|
integration = loader.Integration(
|
||||||
|
@ -5872,6 +5884,15 @@ async def test_in_progress_get_canceled_when_entry_is_created(
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
return self.async_create_entry(title="Test Title", data=user_input)
|
return self.async_create_entry(title="Test Title", data=user_input)
|
||||||
|
|
||||||
|
await self.async_set_unique_id(flow_1_unique_id, raise_on_progress=False)
|
||||||
|
return self.async_show_form(step_id="user")
|
||||||
|
|
||||||
|
async def async_step_zeroconfg(self, user_input=None):
|
||||||
|
"""Test user step."""
|
||||||
|
if user_input is not None:
|
||||||
|
return self.async_create_entry(title="Test Title", data=user_input)
|
||||||
|
|
||||||
|
await self.async_set_unique_id(flow_2_unique_id, raise_on_progress=False)
|
||||||
return self.async_show_form(step_id="user")
|
return self.async_show_form(step_id="user")
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
|
Loading…
Reference in New Issue