|
6 | 6 |
|
7 | 7 | from homeassistant import config_entries |
8 | 8 | from homeassistant.components.steamist.const import DOMAIN |
| 9 | +from homeassistant.config_entries import SOURCE_IGNORE |
9 | 10 | from homeassistant.const import CONF_DEVICE, CONF_HOST |
10 | 11 | from homeassistant.core import HomeAssistant |
11 | 12 | from homeassistant.data_entry_flow import FlowResultType |
@@ -413,3 +414,48 @@ async def test_discovered_by_dhcp_or_discovery_existing_unique_id_does_not_reloa |
413 | 414 | assert result["reason"] == "already_configured" |
414 | 415 | assert not mock_setup.called |
415 | 416 | assert not mock_setup_entry.called |
| 417 | + |
| 418 | + |
| 419 | +async def test_pick_device_replaces_ignored_device(hass: HomeAssistant) -> None: |
| 420 | + """Test the pick device step can replace an ignored device.""" |
| 421 | + entry = MockConfigEntry( |
| 422 | + domain=DOMAIN, |
| 423 | + unique_id=FORMATTED_MAC_ADDRESS, |
| 424 | + source=SOURCE_IGNORE, |
| 425 | + data={}, |
| 426 | + ) |
| 427 | + entry.add_to_hass(hass) |
| 428 | + |
| 429 | + with _patch_discovery(), _patch_status(MOCK_ASYNC_GET_STATUS_INACTIVE): |
| 430 | + result = await hass.config_entries.flow.async_init( |
| 431 | + DOMAIN, context={"source": config_entries.SOURCE_USER} |
| 432 | + ) |
| 433 | + await hass.async_block_till_done() |
| 434 | + assert result["type"] is FlowResultType.FORM |
| 435 | + assert result["step_id"] == "user" |
| 436 | + |
| 437 | + result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) |
| 438 | + await hass.async_block_till_done() |
| 439 | + |
| 440 | + assert result2["type"] is FlowResultType.FORM |
| 441 | + assert result2["step_id"] == "pick_device" |
| 442 | + |
| 443 | + # Verify the ignored device is in the dropdown |
| 444 | + assert FORMATTED_MAC_ADDRESS in result2["data_schema"].schema[CONF_DEVICE].container |
| 445 | + |
| 446 | + with ( |
| 447 | + _patch_discovery(), |
| 448 | + _patch_status(MOCK_ASYNC_GET_STATUS_INACTIVE), |
| 449 | + patch(f"{MODULE}.async_setup", return_value=True), |
| 450 | + patch(f"{MODULE}.async_setup_entry", return_value=True), |
| 451 | + ): |
| 452 | + result3 = await hass.config_entries.flow.async_configure( |
| 453 | + result2["flow_id"], |
| 454 | + {CONF_DEVICE: FORMATTED_MAC_ADDRESS}, |
| 455 | + ) |
| 456 | + await hass.async_block_till_done() |
| 457 | + |
| 458 | + assert result3["type"] is FlowResultType.CREATE_ENTRY |
| 459 | + assert result3["title"] == DEVICE_NAME |
| 460 | + assert result3["data"] == DEFAULT_ENTRY_DATA |
| 461 | + assert result3["result"].unique_id == FORMATTED_MAC_ADDRESS |
0 commit comments