From 0b79504cf033db88120e5f2ea60d700d742a57f0 Mon Sep 17 00:00:00 2001 From: Jan-Philipp Benecke Date: Mon, 22 Jan 2024 23:01:55 +0100 Subject: [PATCH] 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 --- homeassistant/config_entries.py | 3 +++ tests/test_config_entries.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index 79c36658417..7eee83953a7 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -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, diff --git a/tests/test_config_entries.py b/tests/test_config_entries.py index 14224b95fc9..db382ac35f4 100644 --- a/tests/test_config_entries.py +++ b/tests/test_config_entries.py @@ -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