Add siren support for available tones provided as a dict (#54198)
* Add siren support for available tones provided as a dict * remove paranthesis * hopefully make logic even easier to read * drop last parenthesis
This commit is contained in:
parent
557cc792e9
commit
2e903c92c4
2 changed files with 50 additions and 8 deletions
|
@ -48,9 +48,32 @@ async def test_no_available_tones(hass):
|
|||
process_turn_on_params(siren, {"tone": "test"})
|
||||
|
||||
|
||||
async def test_missing_tones(hass):
|
||||
"""Test ValueError when setting a tone that is missing from available_tones."""
|
||||
async def test_available_tones_list(hass):
|
||||
"""Test that valid tones from tone list will get passed in."""
|
||||
siren = MockSirenEntity(SUPPORT_TONES, ["a", "b"])
|
||||
siren.hass = hass
|
||||
assert process_turn_on_params(siren, {"tone": "a"}) == {"tone": "a"}
|
||||
|
||||
|
||||
async def test_available_tones_dict(hass):
|
||||
"""Test that valid tones from available_tones dict will get passed in."""
|
||||
siren = MockSirenEntity(SUPPORT_TONES, {1: "a", 2: "b"})
|
||||
siren.hass = hass
|
||||
assert process_turn_on_params(siren, {"tone": "a"}) == {"tone": 1}
|
||||
assert process_turn_on_params(siren, {"tone": 1}) == {"tone": 1}
|
||||
|
||||
|
||||
async def test_missing_tones_list(hass):
|
||||
"""Test ValueError when setting a tone that is missing from available_tones list."""
|
||||
siren = MockSirenEntity(SUPPORT_TONES, ["a", "b"])
|
||||
siren.hass = hass
|
||||
with pytest.raises(ValueError):
|
||||
process_turn_on_params(siren, {"tone": "test"})
|
||||
|
||||
|
||||
async def test_missing_tones_dict(hass):
|
||||
"""Test ValueError when setting a tone that is missing from available_tones dict."""
|
||||
siren = MockSirenEntity(SUPPORT_TONES, {1: "a", 2: "b"})
|
||||
siren.hass = hass
|
||||
with pytest.raises(ValueError):
|
||||
process_turn_on_params(siren, {"tone": 3})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue