mirror of
https://github.com/home-assistant/core.git
synced 2026-02-15 07:36:16 +00:00
Make sure user flow replace ignored in gardena_blueooth (#154778)
This commit is contained in:
@@ -128,7 +128,7 @@ class GardenaBluetoothConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
self._abort_if_unique_id_configured()
|
||||
return await self.async_step_confirm()
|
||||
|
||||
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):
|
||||
address = discovery_info.address
|
||||
if address in current_addresses or not _is_supported(discovery_info):
|
||||
|
||||
@@ -25,7 +25,9 @@ from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
def mock_entry():
|
||||
"""Create hass config fixture."""
|
||||
return MockConfigEntry(
|
||||
domain=DOMAIN, data={CONF_ADDRESS: WATER_TIMER_SERVICE_INFO.address}
|
||||
domain=DOMAIN,
|
||||
data={CONF_ADDRESS: WATER_TIMER_SERVICE_INFO.address},
|
||||
unique_id=WATER_TIMER_SERVICE_INFO.address,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@ from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.gardena_bluetooth.const import DOMAIN
|
||||
from homeassistant.const import CONF_ADDRESS
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from . import (
|
||||
MISSING_MANUFACTURER_DATA_SERVICE_INFO,
|
||||
@@ -18,6 +20,7 @@ from . import (
|
||||
WATER_TIMER_UNNAMED_SERVICE_INFO,
|
||||
)
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.components.bluetooth import inject_bluetooth_service_info
|
||||
|
||||
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
||||
@@ -51,6 +54,39 @@ async def test_user_selection(
|
||||
assert result == snapshot
|
||||
|
||||
|
||||
async def test_user_selection_replaces_ignored(hass: HomeAssistant) -> None:
|
||||
"""Test setup from service info cache replaces an ignored entry."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
unique_id=WATER_TIMER_SERVICE_INFO.address,
|
||||
)
|
||||
entry.source = config_entries.SOURCE_IGNORE
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
inject_bluetooth_service_info(hass, WATER_TIMER_SERVICE_INFO)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={CONF_ADDRESS: WATER_TIMER_SERVICE_INFO.address},
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={},
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_failed_connect(
|
||||
hass: HomeAssistant,
|
||||
mock_client: Mock,
|
||||
|
||||
Reference in New Issue
Block a user