Skip to content

Commit

Permalink
Remove unignore flow from dlna_dmr (#126647)
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery authored Sep 24, 2024
1 parent fc37218 commit 2ded9d5
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 102 deletions.
25 changes: 0 additions & 25 deletions homeassistant/components/dlna_dmr/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,31 +195,6 @@ async def async_step_ignore(
},
)

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:
Expand Down
77 changes: 0 additions & 77 deletions tests/components/dlna_dmr/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 2ded9d5

Please sign in to comment.