|
7 | 7 |
|
8 | 8 | from homeassistant import config_entries |
9 | 9 | from homeassistant.components.snooz import DOMAIN |
| 10 | +from homeassistant.config_entries import SOURCE_IGNORE |
10 | 11 | from homeassistant.const import CONF_ADDRESS, CONF_NAME, CONF_TOKEN |
11 | 12 | from homeassistant.core import HomeAssistant |
12 | 13 | from homeassistant.data_entry_flow import FlowResultType |
@@ -265,6 +266,34 @@ async def test_async_step_user_takes_precedence_over_discovery( |
265 | 266 | assert not hass.config_entries.flow.async_progress() |
266 | 267 |
|
267 | 268 |
|
| 269 | +async def test_user_setup_replaces_ignored_device(hass: HomeAssistant) -> None: |
| 270 | + """Test the user initiated form can replace an ignored device.""" |
| 271 | + entry = MockConfigEntry( |
| 272 | + domain=DOMAIN, |
| 273 | + unique_id=TEST_ADDRESS, |
| 274 | + source=SOURCE_IGNORE, |
| 275 | + data={}, |
| 276 | + ) |
| 277 | + entry.add_to_hass(hass) |
| 278 | + |
| 279 | + with patch( |
| 280 | + "homeassistant.components.snooz.config_flow.async_discovered_service_info", |
| 281 | + return_value=[SNOOZ_SERVICE_INFO_PAIRING], |
| 282 | + ): |
| 283 | + result = await hass.config_entries.flow.async_init( |
| 284 | + DOMAIN, context={"source": config_entries.SOURCE_USER} |
| 285 | + ) |
| 286 | + assert result["type"] is FlowResultType.FORM |
| 287 | + assert result["step_id"] == "user" |
| 288 | + |
| 289 | + # Verify the ignored device is in the dropdown |
| 290 | + assert result["data_schema"].schema["name"].container == [TEST_SNOOZ_DISPLAY_NAME] |
| 291 | + |
| 292 | + await _test_setup_entry( |
| 293 | + hass, result["flow_id"], {CONF_NAME: TEST_SNOOZ_DISPLAY_NAME} |
| 294 | + ) |
| 295 | + |
| 296 | + |
268 | 297 | async def _test_pairs( |
269 | 298 | hass: HomeAssistant, flow_id: str, user_input: dict | None = None |
270 | 299 | ) -> None: |
|
0 commit comments