mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 14:57:09 +00:00
Don't update existing Fronius config entries from config flow (#132886)
This commit is contained in:
parent
760c3ac98c
commit
aa4b64386e
@ -60,7 +60,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: FroniusConfigEntry) ->
|
||||
|
||||
|
||||
async def async_remove_config_entry_device(
|
||||
hass: HomeAssistant, config_entry: ConfigEntry, device_entry: dr.DeviceEntry
|
||||
hass: HomeAssistant, config_entry: FroniusConfigEntry, device_entry: dr.DeviceEntry
|
||||
) -> bool:
|
||||
"""Remove a config entry from a device."""
|
||||
return True
|
||||
|
@ -87,7 +87,7 @@ class FroniusConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
errors["base"] = "unknown"
|
||||
else:
|
||||
await self.async_set_unique_id(unique_id, raise_on_progress=False)
|
||||
self._abort_if_unique_id_configured(updates=dict(info))
|
||||
self._abort_if_unique_id_configured()
|
||||
|
||||
return self.async_create_entry(title=create_title(info), data=info)
|
||||
|
||||
|
@ -205,10 +205,10 @@ async def test_form_already_existing(hass: HomeAssistant) -> None:
|
||||
assert result2["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_form_updates_host(
|
||||
async def test_config_flow_already_configured(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test existing entry gets updated."""
|
||||
"""Test existing entry doesn't get updated by config flow."""
|
||||
old_host = "http://10.1.0.1"
|
||||
new_host = "http://10.1.0.2"
|
||||
entry = MockConfigEntry(
|
||||
@ -231,10 +231,6 @@ async def test_form_updates_host(
|
||||
)
|
||||
|
||||
mock_responses(aioclient_mock, host=new_host)
|
||||
with patch(
|
||||
"homeassistant.components.fronius.async_unload_entry",
|
||||
return_value=True,
|
||||
) as mock_unload_entry:
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{
|
||||
@ -242,15 +238,13 @@ async def test_form_updates_host(
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_configured"
|
||||
|
||||
mock_unload_entry.assert_called_with(hass, entry)
|
||||
entries = hass.config_entries.async_entries(DOMAIN)
|
||||
assert len(entries) == 1
|
||||
assert entries[0].data == {
|
||||
"host": new_host,
|
||||
"host": old_host, # not updated from config flow - only from reconfigure flow
|
||||
"is_logger": True,
|
||||
}
|
||||
|
||||
@ -326,11 +320,13 @@ async def test_dhcp_invalid(
|
||||
|
||||
async def test_reconfigure(hass: HomeAssistant) -> None:
|
||||
"""Test reconfiguring an entry."""
|
||||
old_host = "http://10.1.0.1"
|
||||
new_host = "http://10.1.0.2"
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
unique_id="1234567",
|
||||
data={
|
||||
CONF_HOST: "10.1.2.3",
|
||||
CONF_HOST: old_host,
|
||||
"is_logger": True,
|
||||
},
|
||||
)
|
||||
@ -357,7 +353,7 @@ async def test_reconfigure(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
"host": "10.9.1.1",
|
||||
"host": new_host,
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
@ -365,7 +361,7 @@ async def test_reconfigure(hass: HomeAssistant) -> None:
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reconfigure_successful"
|
||||
assert entry.data == {
|
||||
"host": "10.9.1.1",
|
||||
"host": new_host,
|
||||
"is_logger": False,
|
||||
}
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user