Add EntityFeature enum to Siren (#69585)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
340dd3ab82
commit
a61ac3ddc6
3 changed files with 39 additions and 15 deletions
|
@ -4,7 +4,7 @@ from unittest.mock import MagicMock
|
|||
import pytest
|
||||
|
||||
from homeassistant.components.siren import SirenEntity, process_turn_on_params
|
||||
from homeassistant.components.siren.const import SUPPORT_TONES
|
||||
from homeassistant.components.siren.const import SirenEntityFeature
|
||||
|
||||
|
||||
class MockSirenEntity(SirenEntity):
|
||||
|
@ -42,7 +42,7 @@ async def test_sync_turn_off(hass):
|
|||
|
||||
async def test_no_available_tones(hass):
|
||||
"""Test ValueError when siren advertises tones but has no available_tones."""
|
||||
siren = MockSirenEntity(SUPPORT_TONES)
|
||||
siren = MockSirenEntity(SirenEntityFeature.TONES)
|
||||
siren.hass = hass
|
||||
with pytest.raises(ValueError):
|
||||
process_turn_on_params(siren, {"tone": "test"})
|
||||
|
@ -50,14 +50,14 @@ async def test_no_available_tones(hass):
|
|||
|
||||
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 = MockSirenEntity(SirenEntityFeature.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 = MockSirenEntity(SirenEntityFeature.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}
|
||||
|
@ -65,7 +65,7 @@ async def test_available_tones_dict(hass):
|
|||
|
||||
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 = MockSirenEntity(SirenEntityFeature.TONES, ["a", "b"])
|
||||
siren.hass = hass
|
||||
with pytest.raises(ValueError):
|
||||
process_turn_on_params(siren, {"tone": "test"})
|
||||
|
@ -73,7 +73,7 @@ async def test_missing_tones_list(hass):
|
|||
|
||||
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 = MockSirenEntity(SirenEntityFeature.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