Allow ignored IronOS devices to be set up from the user flow (#138223)
parent
7aab1de72d
commit
5529fbdc94
|
@ -61,7 +61,7 @@ class IronOSConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
return self.async_create_entry(title=title, data={})
|
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):
|
for discovery_info in async_discovered_service_info(self.hass, True):
|
||||||
address = discovery_info.address
|
address = discovery_info.address
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -24,6 +24,7 @@ from pynecil import (
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.iron_os import DOMAIN
|
from homeassistant.components.iron_os import DOMAIN
|
||||||
|
from homeassistant.config_entries import SOURCE_IGNORE
|
||||||
from homeassistant.const import CONF_ADDRESS
|
from homeassistant.const import CONF_ADDRESS
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
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")
|
@pytest.fixture(name="ble_device")
|
||||||
def mock_ble_device() -> Generator[MagicMock]:
|
def mock_ble_device() -> Generator[MagicMock]:
|
||||||
"""Mock BLEDevice."""
|
"""Mock BLEDevice."""
|
||||||
|
|
|
@ -106,3 +106,28 @@ async def test_async_step_bluetooth_devices_already_setup(
|
||||||
)
|
)
|
||||||
assert result["type"] is FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
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"
|
||||||
|
|
Loading…
Reference in New Issue