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:
@@ -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"]}
|
||||
|
||||
Reference in New Issue
Block a user