Fix ignoring elkm1 discovery (#68750)

pull/68825/head
J. Nick Koston 2022-03-27 23:05:50 -10:00 committed by Paulus Schoutsen
parent d1a6eb55b1
commit 9acd1471a0
2 changed files with 24 additions and 0 deletions

View File

@ -181,6 +181,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
for progress in self._async_in_progress():
if progress.get("context", {}).get(CONF_HOST) == host:
return self.async_abort(reason="already_in_progress")
# Handled ignored case since _async_current_entries
# is called with include_ignore=False
self._abort_if_unique_id_configured()
if not device.port:
if discovered_device := await async_discover_device(self.hass, host):
self._discovered_device = discovered_device

View File

@ -30,6 +30,27 @@ ELK_DISCOVERY_INFO_NON_STANDARD_PORT = asdict(ELK_DISCOVERY_NON_STANDARD_PORT)
MODULE = "homeassistant.components.elkm1"
async def test_discovery_ignored_entry(hass):
"""Test we abort on ignored entry."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_HOST: f"elks://{MOCK_IP_ADDRESS}"},
unique_id="aa:bb:cc:dd:ee:ff",
source=config_entries.SOURCE_IGNORE,
)
config_entry.add_to_hass(hass)
with _patch_discovery(), _patch_elk():
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_INTEGRATION_DISCOVERY},
data=ELK_DISCOVERY_INFO,
)
await hass.async_block_till_done()
assert result["type"] == RESULT_TYPE_ABORT
assert result["reason"] == "already_configured"
async def test_form_user_with_secure_elk_no_discovery(hass):
"""Test we can setup a secure elk."""