Allow ignored IronOS devices to be set up from the user flow (#138223)

pull/138201/head^2
Manu 2025-02-10 20:18:31 +01:00 committed by GitHub
parent 7aab1de72d
commit 5529fbdc94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 40 additions and 1 deletions

View File

@ -61,7 +61,7 @@ class IronOSConfigFlow(ConfigFlow, domain=DOMAIN):
self._abort_if_unique_id_configured()
return self.async_create_entry(title=title, data={})
current_addresses = self._async_current_ids()
current_addresses = self._async_current_ids(include_ignore=False)
for discovery_info in async_discovered_service_info(self.hass, True):
address = discovery_info.address
if (

View File

@ -24,6 +24,7 @@ from pynecil import (
import pytest
from homeassistant.components.iron_os import DOMAIN
from homeassistant.config_entries import SOURCE_IGNORE
from homeassistant.const import CONF_ADDRESS
from tests.common import MockConfigEntry
@ -110,6 +111,19 @@ def mock_config_entry() -> MockConfigEntry:
)
@pytest.fixture(name="config_entry_ignored")
def mock_config_entry_ignored() -> MockConfigEntry:
"""Mock Pinecil configuration entry for ignored device."""
return MockConfigEntry(
domain=DOMAIN,
title=DEFAULT_NAME,
data={},
unique_id="c0:ff:ee:c0:ff:ee",
entry_id="1234567890",
source=SOURCE_IGNORE,
)
@pytest.fixture(name="ble_device")
def mock_ble_device() -> Generator[MagicMock]:
"""Mock BLEDevice."""

View File

@ -106,3 +106,28 @@ async def test_async_step_bluetooth_devices_already_setup(
)
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@pytest.mark.usefixtures("discovery")
async def test_async_step_user_setup_replaces_igonored_device(
hass: HomeAssistant, config_entry_ignored: AsyncMock
) -> None:
"""Test the user initiated form can replace an ignored device."""
config_entry_ignored.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
USER_INPUT,
)
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == DEFAULT_NAME
assert result["data"] == {}
assert result["result"].unique_id == "c0:ff:ee:c0:ff:ee"