From 5c0dd2e09b4f8ca2d6fef51a7827046a0cd0f026 Mon Sep 17 00:00:00 2001 From: Erik Date: Sun, 11 Apr 2021 13:30:35 +0200 Subject: [PATCH] Fix cast options flow overwriting data --- homeassistant/components/cast/config_flow.py | 2 +- tests/components/cast/test_config_flow.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/cast/config_flow.py b/homeassistant/components/cast/config_flow.py index 464283e07f30cc..86d85588967e30 100644 --- a/homeassistant/components/cast/config_flow.py +++ b/homeassistant/components/cast/config_flow.py @@ -133,7 +133,7 @@ async def async_step_options(self, user_input=None): ) if not bad_cec and not bad_hosts and not bad_uuid: - updated_config = {} + updated_config = dict(current_config) updated_config[CONF_IGNORE_CEC] = ignore_cec updated_config[CONF_KNOWN_HOSTS] = known_hosts updated_config[CONF_UUID] = wanted_uuid diff --git a/tests/components/cast/test_config_flow.py b/tests/components/cast/test_config_flow.py index 064406df717aac..1febd9d880324d 100644 --- a/tests/components/cast/test_config_flow.py +++ b/tests/components/cast/test_config_flow.py @@ -166,6 +166,7 @@ async def test_option_flow(hass, parameter_data): assert result["step_id"] == "options" data_schema = result["data_schema"].schema assert set(data_schema) == {"known_hosts"} + orig_data = dict(config_entry.data) # Reconfigure ignore_cec, known_hosts, uuid context = {"source": "user", "show_advanced_options": True} @@ -201,7 +202,12 @@ async def test_option_flow(hass, parameter_data): ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result["data"] is None - assert config_entry.data == {"ignore_cec": [], "known_hosts": [], "uuid": []} + assert config_entry.data == { + **orig_data, + "ignore_cec": [], + "known_hosts": [], + "uuid": [], + } async def test_known_hosts(hass, castbrowser_mock, castbrowser_constructor_mock):