Test for async_show_menu sort (#151630)
parent
111fa78c57
commit
3385151c26
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue