* Initial commit * Update homeassistant/components/tradfri/const.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Feedback * Updates * Remove logger * Fix codestring * Update homeassistant/components/tradfri/fan.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/components/tradfri/fan.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/components/tradfri/fan.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Percent value * Add tests * Typo * Update tests * Fix util function * Update homeassistant/components/tradfri/fan.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Update after review * Review * Coverage * Fix test Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
22 lines
595 B
Python
22 lines
595 B
Python
"""Tradfri utility function tests."""
|
|
|
|
from homeassistant.components.tradfri.fan import _from_fan_speed, _from_percentage
|
|
|
|
|
|
def test_from_fan_speed():
|
|
"""Test that we can convert fan speed to percentage value."""
|
|
assert _from_fan_speed(41) == 80
|
|
|
|
|
|
def test_from_percentage():
|
|
"""Test that we can convert percentage value to fan speed."""
|
|
assert _from_percentage(84) == 40
|
|
|
|
|
|
def test_from_percentage_limit():
|
|
"""
|
|
Test that we can convert percentage value to fan speed.
|
|
|
|
Handle special case of percent value being below 20.
|
|
"""
|
|
assert _from_percentage(10) == 0
|