Add error handling to input_select integration (#93940)

This commit is contained in:
j4n-e4t 2023-06-05 19:53:24 +02:00 committed by GitHub
parent e2c2262719
commit 28f6062bab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 18 deletions

View file

@ -102,12 +102,13 @@ async def test_select_option(hass: HomeAssistant) -> None:
state = hass.states.get(entity_id)
assert state.state == "another option"
await hass.services.async_call(
DOMAIN,
SERVICE_SELECT_OPTION,
{ATTR_ENTITY_ID: entity_id, ATTR_OPTION: "non existing option"},
blocking=True,
)
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
DOMAIN,
SERVICE_SELECT_OPTION,
{ATTR_ENTITY_ID: entity_id, ATTR_OPTION: "non existing option"},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == "another option"
@ -305,12 +306,13 @@ async def test_set_options_service(hass: HomeAssistant) -> None:
state = hass.states.get(entity_id)
assert state.state == "test1"
await hass.services.async_call(
DOMAIN,
SERVICE_SELECT_OPTION,
{ATTR_ENTITY_ID: entity_id, ATTR_OPTION: "first option"},
blocking=True,
)
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
DOMAIN,
SERVICE_SELECT_OPTION,
{ATTR_ENTITY_ID: entity_id, ATTR_OPTION: "first option"},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == "test1"