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(
|
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:
|
) -> bool:
|
||||||
"""Remove a config entry from a device."""
|
"""Remove a config entry from a device."""
|
||||||
return True
|
return True
|
||||||
|
@ -87,7 +87,7 @@ class FroniusConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
await self.async_set_unique_id(unique_id, raise_on_progress=False)
|
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)
|
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"
|
assert result2["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
async def test_form_updates_host(
|
async def test_config_flow_already_configured(
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test existing entry gets updated."""
|
"""Test existing entry doesn't get updated by config flow."""
|
||||||
old_host = "http://10.1.0.1"
|
old_host = "http://10.1.0.1"
|
||||||
new_host = "http://10.1.0.2"
|
new_host = "http://10.1.0.2"
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
@ -231,26 +231,20 @@ async def test_form_updates_host(
|
|||||||
)
|
)
|
||||||
|
|
||||||
mock_responses(aioclient_mock, host=new_host)
|
mock_responses(aioclient_mock, host=new_host)
|
||||||
with patch(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
"homeassistant.components.fronius.async_unload_entry",
|
result["flow_id"],
|
||||||
return_value=True,
|
{
|
||||||
) as mock_unload_entry:
|
"host": new_host,
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
},
|
||||||
result["flow_id"],
|
)
|
||||||
{
|
await hass.async_block_till_done()
|
||||||
"host": new_host,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
assert result2["type"] is FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_configured"
|
assert result2["reason"] == "already_configured"
|
||||||
|
|
||||||
mock_unload_entry.assert_called_with(hass, entry)
|
|
||||||
entries = hass.config_entries.async_entries(DOMAIN)
|
entries = hass.config_entries.async_entries(DOMAIN)
|
||||||
assert len(entries) == 1
|
assert len(entries) == 1
|
||||||
assert entries[0].data == {
|
assert entries[0].data == {
|
||||||
"host": new_host,
|
"host": old_host, # not updated from config flow - only from reconfigure flow
|
||||||
"is_logger": True,
|
"is_logger": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,11 +320,13 @@ async def test_dhcp_invalid(
|
|||||||
|
|
||||||
async def test_reconfigure(hass: HomeAssistant) -> None:
|
async def test_reconfigure(hass: HomeAssistant) -> None:
|
||||||
"""Test reconfiguring an entry."""
|
"""Test reconfiguring an entry."""
|
||||||
|
old_host = "http://10.1.0.1"
|
||||||
|
new_host = "http://10.1.0.2"
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
unique_id="1234567",
|
unique_id="1234567",
|
||||||
data={
|
data={
|
||||||
CONF_HOST: "10.1.2.3",
|
CONF_HOST: old_host,
|
||||||
"is_logger": True,
|
"is_logger": True,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -357,7 +353,7 @@ async def test_reconfigure(hass: HomeAssistant) -> None:
|
|||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={
|
user_input={
|
||||||
"host": "10.9.1.1",
|
"host": new_host,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
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["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reconfigure_successful"
|
assert result["reason"] == "reconfigure_successful"
|
||||||
assert entry.data == {
|
assert entry.data == {
|
||||||
"host": "10.9.1.1",
|
"host": new_host,
|
||||||
"is_logger": False,
|
"is_logger": False,
|
||||||
}
|
}
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user