1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-26 14:08:21 +00:00

Separate fan speeds into percentages and presets modes (#45407)

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: John Carr <john.carr@unrouted.co.uk>
This commit is contained in:
J. Nick Koston
2021-01-27 17:44:36 -06:00
committed by GitHub
parent 3f948e027a
commit 068d1b5eb8
36 changed files with 1607 additions and 112 deletions

View File

@@ -2,7 +2,7 @@
import pytest
from homeassistant.components.fan import FanEntity
from homeassistant.components.fan import FanEntity, NotValidPresetModeError
class BaseFan(FanEntity):
@@ -17,6 +17,7 @@ def test_fanentity():
fan = BaseFan()
assert fan.state == "off"
assert len(fan.speed_list) == 0
assert len(fan.preset_modes) == 0
assert fan.supported_features == 0
assert fan.capability_attributes == {}
# Test set_speed not required
@@ -24,7 +25,35 @@ def test_fanentity():
fan.oscillate(True)
with pytest.raises(NotImplementedError):
fan.set_speed("slow")
with pytest.raises(NotImplementedError):
fan.set_percentage(0)
with pytest.raises(NotValidPresetModeError):
fan.set_preset_mode("auto")
with pytest.raises(NotImplementedError):
fan.turn_on()
with pytest.raises(NotImplementedError):
fan.turn_off()
async def test_async_fanentity(hass):
"""Test async fan entity methods."""
fan = BaseFan()
fan.hass = hass
assert fan.state == "off"
assert len(fan.speed_list) == 0
assert len(fan.preset_modes) == 0
assert fan.supported_features == 0
assert fan.capability_attributes == {}
# Test set_speed not required
with pytest.raises(NotImplementedError):
await fan.async_oscillate(True)
with pytest.raises(NotImplementedError):
await fan.async_set_speed("slow")
with pytest.raises(NotImplementedError):
await fan.async_set_percentage(0)
with pytest.raises(NotValidPresetModeError):
await fan.async_set_preset_mode("auto")
with pytest.raises(NotImplementedError):
await fan.async_turn_on()
with pytest.raises(NotImplementedError):
await fan.async_turn_off()