Test for async_show_menu sort (#151630)

pull/151637/head
karwosts 2025-09-03 09:46:57 -07:00 committed by GitHub
parent 111fa78c57
commit 3385151c26
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 2 deletions

View File

@ -1071,13 +1071,19 @@ async def test_manager_abort_calls_async_flow_removed(manager: MockFlowManager)
@pytest.mark.parametrize(
"menu_options",
[["target1", "target2"], {"target1": "Target 1", "target2": "Target 2"}],
("menu_options", "sort", "expect_sort"),
[
(["target1", "target2"], None, None),
({"target1": "Target 1", "target2": "Target 2"}, False, None),
(["target2", "target1"], True, True),
],
)
async def test_show_menu(
hass: HomeAssistant,
manager: MockFlowManager,
menu_options: list[str] | dict[str, str],
sort: bool | None,
expect_sort: bool | None,
) -> None:
"""Test show menu."""
manager.hass = hass
@ -1093,6 +1099,7 @@ async def test_show_menu(
step_id="init",
menu_options=menu_options,
description_placeholders={"name": "Paulus"},
sort=sort,
)
async def async_step_target1(self, user_input=None):
@ -1105,6 +1112,7 @@ async def test_show_menu(
assert result["type"] == data_entry_flow.FlowResultType.MENU
assert result["menu_options"] == menu_options
assert result["description_placeholders"] == {"name": "Paulus"}
assert result.get("sort") == expect_sort
assert len(manager.async_progress()) == 1
assert len(manager.async_progress_by_handler("test")) == 1
assert manager.async_get(result["flow_id"])["handler"] == "test"