Validate tone is valid when processing siren.turn_on service call (#52953)
* Validate tone is valid when processing siren.turn_on service call * Better message
This commit is contained in:
parent
ac39607ae9
commit
30def802fc
2 changed files with 23 additions and 3 deletions
|
@ -5,6 +5,7 @@ import pytest
|
|||
|
||||
from homeassistant.components.siren.const import (
|
||||
ATTR_AVAILABLE_TONES,
|
||||
ATTR_TONE,
|
||||
ATTR_VOLUME_LEVEL,
|
||||
DOMAIN,
|
||||
)
|
||||
|
@ -56,6 +57,15 @@ async def test_turn_on(hass):
|
|||
state = hass.states.get(ENTITY_SIREN)
|
||||
assert state.state == STATE_ON
|
||||
|
||||
# Test that an invalid tone will raise a ValueError
|
||||
with pytest.raises(ValueError):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: ENTITY_SIREN_WITH_ALL_FEATURES, ATTR_TONE: "invalid_tone"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
|
||||
async def test_turn_off(hass):
|
||||
"""Test turn off device."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue