mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
tplink: Fix new host ignored in reconfigure flow (#182184)
This commit is contained in:
@@ -830,7 +830,7 @@ class TPLinkConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
port = reconfigure_entry.data.get(CONF_PORT)
|
||||
|
||||
if user_input is not None:
|
||||
host, port = self._async_get_host_port(host)
|
||||
host, port = self._async_get_host_port(user_input[CONF_HOST])
|
||||
|
||||
self.host = host
|
||||
credentials = await get_credentials(self.hass)
|
||||
|
||||
@@ -2324,13 +2324,29 @@ async def test_reauth_update_other_flows(
|
||||
assert len(flows) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"host",
|
||||
[
|
||||
pytest.param(IP_ADDRESS, id="unchanged_host"),
|
||||
pytest.param("127.0.0.99", id="changed_host"),
|
||||
],
|
||||
)
|
||||
async def test_reconfigure(
|
||||
hass: HomeAssistant,
|
||||
mock_added_config_entry: MockConfigEntry,
|
||||
mock_discovery: AsyncMock,
|
||||
mock_connect: AsyncMock,
|
||||
host: str,
|
||||
) -> None:
|
||||
"""Test reconfigure flow."""
|
||||
device = _mocked_device(
|
||||
device_config=DeviceConfig.from_dict(DEVICE_CONFIG_KLAP.to_dict()),
|
||||
credentials_hash=CREDENTIALS_HASH_KLAP,
|
||||
ip_address=host,
|
||||
)
|
||||
mock_discovery["mock_devices"][host] = device
|
||||
mock_connect["mock_devices"][host] = device
|
||||
|
||||
result = await mock_added_config_entry.start_reconfigure_flow(hass)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@@ -2339,12 +2355,14 @@ async def test_reconfigure(
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
CONF_HOST: IP_ADDRESS,
|
||||
CONF_HOST: host,
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reconfigure_successful"
|
||||
assert mock_added_config_entry.data[CONF_HOST] == host
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
async def test_reconfigure_auth_discovered(
|
||||
@@ -2368,7 +2386,7 @@ async def test_reconfigure_auth_discovered(
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
CONF_HOST: "WRONG_IP",
|
||||
CONF_HOST: IP_ADDRESS,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user