Compare commits

...

3 Commits

Author SHA1 Message Date
Bram Kragten a20ece0bed Merge branch 'dev' into remove-show_advanced_options-from-data-entry-flow-API 2026-05-26 13:55:20 +02:00
Bram Kragten e43d9338ba Update test name 2026-05-26 12:48:50 +02:00
Bram Kragten 2541f306ac Remove from data entry flow API 2026-05-26 12:06:48 +02:00
8 changed files with 16 additions and 44 deletions
@@ -175,7 +175,6 @@ class ConfigManagerFlowIndexView(
vol.Schema(
{
vol.Required("handler"): vol.Any(str, list),
vol.Optional("show_advanced_options", default=False): cv.boolean,
vol.Optional("entry_id"): cv.string,
},
extra=vol.ALLOW_EXTRA,
@@ -302,7 +301,6 @@ class SubentryManagerFlowIndexView(
vol.Schema(
{
vol.Required("handler"): vol.All(vol.Coerce(tuple), (str, str)),
vol.Optional("show_advanced_options", default=False): cv.boolean,
},
extra=vol.ALLOW_EXTRA,
)
-1
View File
@@ -118,7 +118,6 @@ class AbortFlow(FlowError):
class FlowContext(TypedDict, total=False):
"""Typed context dict."""
show_advanced_options: bool
source: str
+1 -2
View File
@@ -60,7 +60,6 @@ class FlowManagerIndexView(_BaseFlowManagerView[_FlowManagerT]):
vol.Schema(
{
vol.Required("handler"): str,
vol.Optional("show_advanced_options", default=False): cv.boolean,
},
extra=vol.ALLOW_EXTRA,
)
@@ -93,7 +92,7 @@ class FlowManagerIndexView(_BaseFlowManagerView[_FlowManagerT]):
def get_context(self, data: dict[str, Any]) -> dict[str, Any]:
"""Return context."""
return {"show_advanced_options": data["show_advanced_options"]}
return {}
class FlowManagerResourceView(_BaseFlowManagerView[_FlowManagerT]):
-6
View File
@@ -1176,8 +1176,6 @@ class MockConfigEntry(config_entries.ConfigEntry):
async def start_reconfigure_flow(
self,
hass: HomeAssistant,
*,
show_advanced_options: bool = False,
) -> ConfigFlowResult:
"""Start a reconfiguration flow."""
if self.entry_id not in hass.config_entries._entries:
@@ -1189,7 +1187,6 @@ class MockConfigEntry(config_entries.ConfigEntry):
context={
"source": config_entries.SOURCE_RECONFIGURE,
"entry_id": self.entry_id,
"show_advanced_options": show_advanced_options,
},
)
@@ -1197,8 +1194,6 @@ class MockConfigEntry(config_entries.ConfigEntry):
self,
hass: HomeAssistant,
subentry_id: str,
*,
show_advanced_options: bool = False,
) -> ConfigFlowResult:
"""Start a subentry reconfiguration flow."""
if self.entry_id not in hass.config_entries._entries:
@@ -1212,7 +1207,6 @@ class MockConfigEntry(config_entries.ConfigEntry):
context={
"source": config_entries.SOURCE_RECONFIGURE,
"subentry_id": subentry_id,
"show_advanced_options": show_advanced_options,
},
)
@@ -419,7 +419,7 @@ async def test_initialize_flow(hass: HomeAssistant, client: TestClient) -> None:
with mock_config_flow("test", TestFlow):
resp = await client.post(
"/api/config/config_entries/flow",
json={"handler": "test", "show_advanced_options": True},
json={"handler": "test"},
)
assert resp.status == HTTPStatus.OK
@@ -469,7 +469,7 @@ async def test_initialize_flow_unmet_dependency(
with mock_config_flow("test2", TestFlow):
resp = await client.post(
"/api/config/config_entries/flow",
json={"handler": "test2", "show_advanced_options": True},
json={"handler": "test2"},
)
assert resp.status == HTTPStatus.BAD_REQUEST
+3 -3
View File
@@ -71,12 +71,12 @@ async def test_form(hass: HomeAssistant) -> None:
assert len(mock_setup_entry.mock_calls) == 1
async def test_form_adv(hass: HomeAssistant) -> None:
"""Test we get the form with advanced options on."""
async def test_form_with_advanced_options(hass: HomeAssistant) -> None:
"""Test we can submit the form with custom resolver and port options."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_USER, "show_advanced_options": True},
context={"source": config_entries.SOURCE_USER},
)
assert result["data_schema"] == DATA_SCHEMA
+7 -13
View File
@@ -317,20 +317,16 @@ async def test_options(
@pytest.mark.parametrize(
("group_type", "extra_options", "extra_options_after", "advanced"),
("group_type", "extra_options", "extra_options_after"),
[
("light", {"all": False}, {"all": False}, False),
("light", {"all": True}, {"all": False}, False),
("light", {"all": False}, {"all": False}, True),
("light", {"all": True}, {"all": False}, True),
("switch", {"all": False}, {"all": False}, False),
("switch", {"all": True}, {"all": False}, False),
("switch", {"all": False}, {"all": False}, True),
("switch", {"all": True}, {"all": False}, True),
("light", {"all": False}, {"all": False}),
("light", {"all": True}, {"all": False}),
("switch", {"all": False}, {"all": False}),
("switch", {"all": True}, {"all": False}),
],
)
async def test_all_options(
hass: HomeAssistant, group_type, extra_options, extra_options_after, advanced
hass: HomeAssistant, group_type, extra_options, extra_options_after
) -> None:
"""Test reconfiguring."""
members1 = [f"{group_type}.one", f"{group_type}.two"]
@@ -356,9 +352,7 @@ async def test_all_options(
config_entry = hass.config_entries.async_entries(DOMAIN)[0]
result = await hass.config_entries.options.async_init(
config_entry.entry_id, context={"show_advanced_options": advanced}
)
result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == group_type
+3 -15
View File
@@ -3,7 +3,6 @@
import asyncio
import dataclasses
import logging
from typing import Any
from unittest.mock import Mock, patch
import pytest
@@ -1275,32 +1274,21 @@ def test_nested_section_in_serializer() -> None:
)
@pytest.mark.parametrize(
("context", "expected_show_advanced"),
[
# The property is deprecated and now unconditionally returns True
({}, True),
({"show_advanced_options": False}, True),
({"show_advanced_options": True}, True),
],
)
async def test_show_advanced_options(
manager: MockFlowManager,
context: dict[str, Any],
expected_show_advanced: bool,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test FlowHandler show_advanced_options property."""
"""Test FlowHandler show_advanced_options property is deprecated and always True."""
@manager.mock_reg_handler("test")
class TestFlow(data_entry_flow.FlowHandler):
VERSION = 5
async def async_step_init(self, info):
assert self.show_advanced_options == expected_show_advanced
assert self.show_advanced_options is True
return self.async_create_entry(title="hello", data={})
await manager.async_init("test", context=context, data={})
await manager.async_init("test", context={}, data={})
assert len(manager.async_progress()) == 0
assert len(manager.mock_created_entries) == 1