2021-10-25 06:15:46 +00:00
|
|
|
"""Tradfri utility function tests."""
|
2022-01-14 03:01:24 +00:00
|
|
|
import pytest
|
2021-10-25 06:15:46 +00:00
|
|
|
|
2022-01-14 03:01:24 +00:00
|
|
|
from homeassistant.components.tradfri.fan import _from_fan_percentage, _from_fan_speed
|
2021-10-25 06:15:46 +00:00
|
|
|
|
|
|
|
|
2022-01-14 03:01:24 +00:00
|
|
|
@pytest.mark.parametrize(
|
2023-02-15 13:09:50 +00:00
|
|
|
("fan_speed", "expected_result"),
|
2022-01-14 03:01:24 +00:00
|
|
|
[
|
|
|
|
(0, 0),
|
|
|
|
(2, 2),
|
|
|
|
(25, 49),
|
|
|
|
(50, 100),
|
|
|
|
],
|
|
|
|
)
|
2023-02-17 15:40:46 +00:00
|
|
|
def test_from_fan_speed(fan_speed, expected_result) -> None:
|
2021-10-25 06:15:46 +00:00
|
|
|
"""Test that we can convert fan speed to percentage value."""
|
2022-01-14 03:01:24 +00:00
|
|
|
assert _from_fan_speed(fan_speed) == expected_result
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
2023-02-15 13:09:50 +00:00
|
|
|
("percentage", "expected_result"),
|
2022-01-14 03:01:24 +00:00
|
|
|
[
|
|
|
|
(1, 2),
|
|
|
|
(100, 50),
|
|
|
|
(50, 26),
|
|
|
|
],
|
|
|
|
)
|
2023-02-17 15:40:46 +00:00
|
|
|
def test_from_percentage(percentage, expected_result) -> None:
|
2021-10-25 06:15:46 +00:00
|
|
|
"""Test that we can convert percentage value to fan speed."""
|
2022-01-14 03:01:24 +00:00
|
|
|
assert _from_fan_percentage(percentage) == expected_result
|