mirror of
https://github.com/home-assistant/core.git
synced 2025-11-20 16:26:57 +00:00
Filter programs by execution type at select program entities at Home Connect (#136950)
* Filter programs by execution type at select program entities * Suggestions and improvements Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Use function and translation key at select program entity description * Fix select entity description docstring --------- Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
committed by
GitHub
parent
889fe05a48
commit
efcfd97d1b
@@ -13,7 +13,11 @@ from aiohomeconnect.model import (
|
||||
ProgramKey,
|
||||
)
|
||||
from aiohomeconnect.model.error import HomeConnectError
|
||||
from aiohomeconnect.model.program import EnumerateProgram
|
||||
from aiohomeconnect.model.program import (
|
||||
EnumerateProgram,
|
||||
EnumerateProgramConstraints,
|
||||
Execution,
|
||||
)
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.select import (
|
||||
@@ -53,25 +57,42 @@ async def test_select(
|
||||
assert config_entry.state is ConfigEntryState.LOADED
|
||||
|
||||
|
||||
async def test_filter_unknown_programs(
|
||||
async def test_filter_programs(
|
||||
config_entry: MockConfigEntry,
|
||||
integration_setup: Callable[[MagicMock], Awaitable[bool]],
|
||||
setup_credentials: None,
|
||||
client: MagicMock,
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test select that only known programs are shown."""
|
||||
"""Test select that only right programs are shown."""
|
||||
client.get_all_programs.side_effect = None
|
||||
client.get_all_programs.return_value = ArrayOfPrograms(
|
||||
[
|
||||
EnumerateProgram(
|
||||
key=ProgramKey.DISHCARE_DISHWASHER_ECO_50,
|
||||
raw_key=ProgramKey.DISHCARE_DISHWASHER_ECO_50.value,
|
||||
constraints=EnumerateProgramConstraints(
|
||||
execution=Execution.SELECT_ONLY,
|
||||
),
|
||||
),
|
||||
EnumerateProgram(
|
||||
key=ProgramKey.UNKNOWN,
|
||||
raw_key="an unknown program",
|
||||
),
|
||||
EnumerateProgram(
|
||||
key=ProgramKey.DISHCARE_DISHWASHER_QUICK_45,
|
||||
raw_key=ProgramKey.DISHCARE_DISHWASHER_QUICK_45.value,
|
||||
constraints=EnumerateProgramConstraints(
|
||||
execution=Execution.START_ONLY,
|
||||
),
|
||||
),
|
||||
EnumerateProgram(
|
||||
key=ProgramKey.DISHCARE_DISHWASHER_AUTO_1,
|
||||
raw_key=ProgramKey.DISHCARE_DISHWASHER_AUTO_1.value,
|
||||
constraints=EnumerateProgramConstraints(
|
||||
execution=Execution.SELECT_AND_START,
|
||||
),
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -82,7 +103,18 @@ async def test_filter_unknown_programs(
|
||||
entity = entity_registry.async_get("select.dishwasher_selected_program")
|
||||
assert entity
|
||||
assert entity.capabilities
|
||||
assert entity.capabilities[ATTR_OPTIONS] == ["dishcare_dishwasher_program_eco_50"]
|
||||
assert entity.capabilities[ATTR_OPTIONS] == [
|
||||
"dishcare_dishwasher_program_eco_50",
|
||||
"dishcare_dishwasher_program_auto_1",
|
||||
]
|
||||
|
||||
entity = entity_registry.async_get("select.dishwasher_active_program")
|
||||
assert entity
|
||||
assert entity.capabilities
|
||||
assert entity.capabilities[ATTR_OPTIONS] == [
|
||||
"dishcare_dishwasher_program_quick_45",
|
||||
"dishcare_dishwasher_program_auto_1",
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
Reference in New Issue
Block a user