mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-06 10:44:04 +00:00
Add T315 fixture, tests for humidity&temperature modules (#802)
This commit is contained in:
0
kasa/tests/smart/modules/__init__.py
Normal file
0
kasa/tests/smart/modules/__init__.py
Normal file
26
kasa/tests/smart/modules/test_humidity.py
Normal file
26
kasa/tests/smart/modules/test_humidity.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import pytest
|
||||
|
||||
from kasa.smart.modules import HumiditySensor
|
||||
from kasa.tests.device_fixtures import parametrize
|
||||
|
||||
humidity = parametrize("has humidity", component_filter="humidity", protocol_filter={"SMART.CHILD"})
|
||||
|
||||
|
||||
@humidity
|
||||
@pytest.mark.parametrize(
|
||||
"feature, type",
|
||||
[
|
||||
("humidity", int),
|
||||
("humidity_warning", bool),
|
||||
],
|
||||
)
|
||||
async def test_humidity_features(dev, feature, type):
|
||||
"""Test that features are registered and work as expected."""
|
||||
humidity: HumiditySensor = dev.modules["HumiditySensor"]
|
||||
|
||||
prop = getattr(humidity, feature)
|
||||
assert isinstance(prop, type)
|
||||
|
||||
feat = humidity._module_features[feature]
|
||||
assert feat.value == prop
|
||||
assert isinstance(feat.value, type)
|
27
kasa/tests/smart/modules/test_temperature.py
Normal file
27
kasa/tests/smart/modules/test_temperature.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import pytest
|
||||
|
||||
from kasa.smart.modules import TemperatureSensor
|
||||
from kasa.tests.device_fixtures import parametrize
|
||||
|
||||
temperature = parametrize("has temperature", component_filter="temperature", protocol_filter={"SMART.CHILD"})
|
||||
|
||||
|
||||
@temperature
|
||||
@pytest.mark.parametrize(
|
||||
"feature, type",
|
||||
[
|
||||
("temperature", float),
|
||||
("temperature_warning", bool),
|
||||
("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)
|
||||
|
||||
feat = temp_module._module_features[feature]
|
||||
assert feat.value == prop
|
||||
assert isinstance(feat.value, type)
|
Reference in New Issue
Block a user