1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-26 14:08:21 +00:00

Add OptionsFlow helper class (#82531)

* Add OptionsFlow helper classes

* More integrations

* Adjust SchemaOptionsFlowHandler

* Use single class

* Simplify access to options

* Reduce PR

* Make _options private

* Add test
This commit is contained in:
epenet
2022-11-24 12:18:09 +01:00
committed by GitHub
parent 7f90fb1cd1
commit 4c38a5d773
3 changed files with 38 additions and 6 deletions

View File

@@ -3426,3 +3426,23 @@ async def test_async_wait_component_startup(hass: HomeAssistant):
# The component has been loaded
assert "test" in hass.config.components
async def test_options_flow_options_not_mutated() -> None:
"""Test that OptionsFlowWithConfigEntry doesn't mutate entry options."""
entry = MockConfigEntry(
domain="test",
data={"first": True},
options={"sub_dict": {"1": "one"}, "sub_list": ["one"]},
)
options_flow = config_entries.OptionsFlowWithConfigEntry(entry)
options_flow._options["sub_dict"]["2"] = "two"
options_flow._options["sub_list"].append("two")
assert options_flow._options == {
"sub_dict": {"1": "one", "2": "two"},
"sub_list": ["one", "two"],
}
assert entry.options == {"sub_dict": {"1": "one"}, "sub_list": ["one"]}