Remove unignore flow from dlna_dmr (#126647)

pull/126652/head
Erik Montnemery 2024-09-24 16:42:01 +02:00 committed by GitHub
parent fc37218311
commit 2ded9d551a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 0 additions and 102 deletions

View File

@ -195,31 +195,6 @@ class DlnaDmrFlowHandler(ConfigFlow, domain=DOMAIN):
},
)
async def async_step_unignore(
self, user_input: Mapping[str, Any]
) -> ConfigFlowResult:
"""Rediscover previously ignored devices by their unique_id."""
LOGGER.debug("async_step_unignore: user_input: %s", user_input)
self._udn = user_input["unique_id"]
assert self._udn
await self.async_set_unique_id(self._udn)
# Find a discovery matching the unignored unique_id for a DMR device
for dev_type in DmrDevice.DEVICE_TYPES:
discovery = await ssdp.async_get_discovery_info_by_udn_st(
self.hass, self._udn, dev_type
)
if discovery:
break
else:
return self.async_abort(reason="discovery_error")
await self._async_set_info_from_discovery(discovery, abort_if_configured=False)
self.context["title_placeholders"] = {"name": self._name}
return await self.async_step_confirm()
async def async_step_confirm(
self, user_input: FlowInput = None
) -> ConfigFlowResult:

View File

@ -671,83 +671,6 @@ async def test_ignore_flow_no_ssdp(
}
async def test_unignore_flow(hass: HomeAssistant, ssdp_scanner_mock: Mock) -> None:
"""Test a config flow started by unignoring a device."""
# Create ignored entry (with no extra info from SSDP)
ssdp_scanner_mock.async_get_discovery_info_by_udn_st.return_value = None
result = await hass.config_entries.flow.async_init(
DLNA_DOMAIN,
context={"source": config_entries.SOURCE_IGNORE},
data={"unique_id": MOCK_DEVICE_UDN, "title": MOCK_DEVICE_NAME},
)
await hass.async_block_till_done()
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_DEVICE_NAME
# Device was found via SSDP, matching the 2nd device type tried
ssdp_scanner_mock.async_get_discovery_info_by_udn_st.side_effect = [
None,
MOCK_DISCOVERY,
None,
None,
None,
]
# Unignore it and expect config flow to start
result = await hass.config_entries.flow.async_init(
DLNA_DOMAIN,
context={"source": config_entries.SOURCE_UNIGNORE},
data={"unique_id": MOCK_DEVICE_UDN},
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
await hass.async_block_till_done()
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_DEVICE_NAME
assert result["data"] == {
CONF_URL: MOCK_DEVICE_LOCATION,
CONF_DEVICE_ID: MOCK_DEVICE_UDN,
CONF_TYPE: MOCK_DEVICE_TYPE,
CONF_MAC: MOCK_MAC_ADDRESS,
}
assert result["options"] == {}
async def test_unignore_flow_offline(
hass: HomeAssistant, ssdp_scanner_mock: Mock
) -> None:
"""Test a config flow started by unignoring a device, but the device is offline."""
# Create ignored entry (with no extra info from SSDP)
ssdp_scanner_mock.async_get_discovery_info_by_udn_st.return_value = None
result = await hass.config_entries.flow.async_init(
DLNA_DOMAIN,
context={"source": config_entries.SOURCE_IGNORE},
data={"unique_id": MOCK_DEVICE_UDN, "title": MOCK_DEVICE_NAME},
)
await hass.async_block_till_done()
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_DEVICE_NAME
# Device is not in the SSDP discoveries (perhaps HA restarted between ignore and unignore)
ssdp_scanner_mock.async_get_discovery_info_by_udn_st.return_value = None
# Unignore it and expect config flow to start then abort
result = await hass.config_entries.flow.async_init(
DLNA_DOMAIN,
context={"source": config_entries.SOURCE_UNIGNORE},
data={"unique_id": MOCK_DEVICE_UDN},
)
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "discovery_error"
async def test_get_mac_address_ipv4(
hass: HomeAssistant, mock_get_mac_address: Mock
) -> None: