|
14 | 14 | OPTION_MAX_VOLUME_DEFAULT, |
15 | 15 | OPTION_VOLUME_RESOLUTION, |
16 | 16 | ) |
17 | | -from homeassistant.config_entries import SOURCE_USER |
| 17 | +from homeassistant.config_entries import SOURCE_IGNORE, SOURCE_USER |
18 | 18 | from homeassistant.const import CONF_HOST |
19 | 19 | from homeassistant.core import HomeAssistant |
20 | 20 | from homeassistant.data_entry_flow import FlowResultType |
@@ -240,6 +240,57 @@ async def test_eiscp_discovery_error( |
240 | 240 | assert result["reason"] == error_reason |
241 | 241 |
|
242 | 242 |
|
| 243 | +async def test_eiscp_discovery_replace_ignored_entry( |
| 244 | + hass: HomeAssistant, mock_config_entry: MockConfigEntry |
| 245 | +) -> None: |
| 246 | + """Test eiscp discovery can replace an ignored config entry.""" |
| 247 | + mock_config_entry.source = SOURCE_IGNORE |
| 248 | + await setup_integration(hass, mock_config_entry) |
| 249 | + |
| 250 | + result = await hass.config_entries.flow.async_init( |
| 251 | + DOMAIN, context={"source": SOURCE_USER} |
| 252 | + ) |
| 253 | + |
| 254 | + assert result["type"] is FlowResultType.MENU |
| 255 | + assert result["step_id"] == "user" |
| 256 | + |
| 257 | + result = await hass.config_entries.flow.async_configure( |
| 258 | + result["flow_id"], {"next_step_id": "eiscp_discovery"} |
| 259 | + ) |
| 260 | + |
| 261 | + assert result["type"] is FlowResultType.FORM |
| 262 | + assert result["step_id"] == "eiscp_discovery" |
| 263 | + |
| 264 | + devices = result["data_schema"].schema["device"].container |
| 265 | + assert devices == { |
| 266 | + RECEIVER_INFO.identifier: _receiver_display_name(RECEIVER_INFO), |
| 267 | + RECEIVER_INFO_2.identifier: _receiver_display_name(RECEIVER_INFO_2), |
| 268 | + } |
| 269 | + |
| 270 | + result = await hass.config_entries.flow.async_configure( |
| 271 | + result["flow_id"], user_input={"device": RECEIVER_INFO.identifier} |
| 272 | + ) |
| 273 | + |
| 274 | + assert result["type"] is FlowResultType.FORM |
| 275 | + assert result["step_id"] == "configure_receiver" |
| 276 | + |
| 277 | + result = await hass.config_entries.flow.async_configure( |
| 278 | + result["flow_id"], |
| 279 | + user_input={ |
| 280 | + OPTION_VOLUME_RESOLUTION: 200, |
| 281 | + OPTION_INPUT_SOURCES: ["TV"], |
| 282 | + OPTION_LISTENING_MODES: ["THX"], |
| 283 | + }, |
| 284 | + ) |
| 285 | + |
| 286 | + assert result["type"] is FlowResultType.CREATE_ENTRY |
| 287 | + assert result["data"][CONF_HOST] == RECEIVER_INFO.host |
| 288 | + assert result["result"].unique_id == RECEIVER_INFO.identifier |
| 289 | + assert result["title"] == RECEIVER_INFO.model_name |
| 290 | + |
| 291 | + assert len(hass.config_entries.async_entries(DOMAIN)) == 1 |
| 292 | + |
| 293 | + |
243 | 294 | @pytest.mark.usefixtures("mock_setup_entry") |
244 | 295 | async def test_ssdp_discovery( |
245 | 296 | hass: HomeAssistant, mock_config_entry: MockConfigEntry |
|
0 commit comments