2024-03-06 18:04:09 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from kasa.smart.modules import TemperatureSensor
|
|
|
|
from kasa.tests.device_fixtures import parametrize
|
|
|
|
|
2024-03-15 15:55:48 +00:00
|
|
|
temperature = parametrize(
|
|
|
|
"has temperature", component_filter="temperature", protocol_filter={"SMART.CHILD"}
|
|
|
|
)
|
2024-03-06 18:04:09 +00:00
|
|
|
|
2024-04-22 14:24:15 +00:00
|
|
|
temperature_warning = parametrize(
|
|
|
|
"has temperature warning",
|
|
|
|
component_filter="comfort_temperature",
|
|
|
|
protocol_filter={"SMART.CHILD"},
|
|
|
|
)
|
|
|
|
|
2024-03-06 18:04:09 +00:00
|
|
|
|
|
|
|
@temperature
|
|
|
|
@pytest.mark.parametrize(
|
2024-08-30 15:30:07 +00:00
|
|
|
("feature", "type"),
|
2024-03-06 18:04:09 +00:00
|
|
|
[
|
|
|
|
("temperature", float),
|
|
|
|
("temperature_unit", str),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
async def test_temperature_features(dev, feature, type):
|
|
|
|
"""Test that features are registered and work as expected."""
|
|
|
|
temp_module: TemperatureSensor = dev.modules["TemperatureSensor"]
|
|
|
|
|
|
|
|
prop = getattr(temp_module, feature)
|
|
|
|
assert isinstance(prop, type)
|
|
|
|
|
2024-05-13 16:34:44 +00:00
|
|
|
feat = dev.features[feature]
|
2024-03-06 18:04:09 +00:00
|
|
|
assert feat.value == prop
|
|
|
|
assert isinstance(feat.value, type)
|
2024-04-22 14:24:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
@temperature_warning
|
|
|
|
async def test_temperature_warning(dev):
|
|
|
|
"""Test that features are registered and work as expected."""
|
|
|
|
temp_module: TemperatureSensor = dev.modules["TemperatureSensor"]
|
|
|
|
|
|
|
|
assert hasattr(temp_module, "temperature_warning")
|
|
|
|
assert isinstance(temp_module.temperature_warning, bool)
|
|
|
|
|
2024-05-13 16:34:44 +00:00
|
|
|
feat = dev.features["temperature_warning"]
|
2024-04-22 14:24:15 +00:00
|
|
|
assert feat.value == temp_module.temperature_warning
|
|
|
|
assert isinstance(feat.value, bool)
|