Prevent nut config flow error when checking ignored entries (#38372)
This commit is contained in:
parent
13e8e28778
commit
1b593e3169
2 changed files with 20 additions and 1 deletions
|
@ -216,6 +216,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
existing_host_port_aliases = {
|
existing_host_port_aliases = {
|
||||||
_format_host_port_alias(entry.data)
|
_format_host_port_alias(entry.data)
|
||||||
for entry in self._async_current_entries()
|
for entry in self._async_current_entries()
|
||||||
|
if CONF_HOST in entry.data
|
||||||
}
|
}
|
||||||
return _format_host_port_alias(user_input) in existing_host_port_aliases
|
return _format_host_port_alias(user_input) in existing_host_port_aliases
|
||||||
|
|
||||||
|
|
|
@ -247,7 +247,25 @@ async def test_form_import_dupe(hass):
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "import"}, data=VALID_CONFIG
|
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=VALID_CONFIG
|
||||||
|
)
|
||||||
|
assert result["type"] == "abort"
|
||||||
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
async def test_form_import_with_ignored_entry(hass):
|
||||||
|
"""Test we get abort on duplicate import when there is an ignored one."""
|
||||||
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||||
|
|
||||||
|
entry = MockConfigEntry(domain=DOMAIN, data=VALID_CONFIG)
|
||||||
|
entry.add_to_hass(hass)
|
||||||
|
ignored_entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN, data={}, source=config_entries.SOURCE_IGNORE
|
||||||
|
)
|
||||||
|
ignored_entry.add_to_hass(hass)
|
||||||
|
|
||||||
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=VALID_CONFIG
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
Loading…
Add table
Reference in a new issue