2024-05-07 18:58:18 +00:00
|
|
|
import pytest
|
|
|
|
|
2024-11-13 16:10:06 +00:00
|
|
|
from kasa import Device, Module
|
2024-11-11 10:11:31 +00:00
|
|
|
|
|
|
|
from ...device_fixtures import parametrize
|
2024-05-07 18:58:18 +00:00
|
|
|
|
|
|
|
contact = parametrize(
|
|
|
|
"is contact sensor", model_filter="T110", protocol_filter={"SMART.CHILD"}
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@contact
|
|
|
|
@pytest.mark.parametrize(
|
2024-08-30 15:30:07 +00:00
|
|
|
("feature", "type"),
|
2024-05-07 18:58:18 +00:00
|
|
|
[
|
|
|
|
("is_open", bool),
|
|
|
|
],
|
|
|
|
)
|
2024-11-13 16:10:06 +00:00
|
|
|
async def test_contact_features(dev: Device, feature, type):
|
2024-05-07 18:58:18 +00:00
|
|
|
"""Test that features are registered and work as expected."""
|
2024-05-10 18:29:28 +00:00
|
|
|
contact = dev.modules.get(Module.ContactSensor)
|
2024-05-07 18:58:18 +00:00
|
|
|
assert contact is not None
|
|
|
|
|
|
|
|
prop = getattr(contact, feature)
|
|
|
|
assert isinstance(prop, type)
|
|
|
|
|
2024-05-13 16:34:44 +00:00
|
|
|
feat = dev.features[feature]
|
2024-05-07 18:58:18 +00:00
|
|
|
assert feat.value == prop
|
|
|
|
assert isinstance(feat.value, type)
|