Extend config entry update/abort helper to also update unique id (#108681)

* Extend config entry update/abort helper to also update unique id

* Move kwarg to end

* Make additionals kwargs only
This commit is contained in:
Jan-Philipp Benecke 2024-01-22 23:01:55 +01:00 committed by GitHub
parent 9ee8832367
commit 0b79504cf0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -1941,6 +1941,8 @@ class ConfigFlow(data_entry_flow.FlowHandler):
def async_update_reload_and_abort(
self,
entry: ConfigEntry,
*,
unique_id: str | None | UndefinedType = UNDEFINED,
title: str | UndefinedType = UNDEFINED,
data: Mapping[str, Any] | UndefinedType = UNDEFINED,
options: Mapping[str, Any] | UndefinedType = UNDEFINED,
@ -1949,6 +1951,7 @@ class ConfigFlow(data_entry_flow.FlowHandler):
"""Update config entry, reload config entry and finish config flow."""
result = self.hass.config_entries.async_update_entry(
entry=entry,
unique_id=unique_id,
title=title,
data=data,
options=options,

View File

@ -4152,6 +4152,7 @@ async def test_update_entry_and_reload(
"""Test updating an entry and reloading."""
entry = MockConfigEntry(
domain="comp",
unique_id="1234",
title="Test",
data={"vendor": "data"},
options={"vendor": "options"},
@ -4172,6 +4173,7 @@ async def test_update_entry_and_reload(
"""Mock Reauth."""
return self.async_update_reload_and_abort(
entry=entry,
unique_id="5678",
title="Updated Title",
data={"vendor": "data2"},
options={"vendor": "options2"},
@ -4182,6 +4184,7 @@ async def test_update_entry_and_reload(
await hass.async_block_till_done()
assert entry.title == "Updated Title"
assert entry.unique_id == "5678"
assert entry.data == {"vendor": "data2"}
assert entry.options == {"vendor": "options2"}
assert entry.state == config_entries.ConfigEntryState.LOADED