2024-05-07 18:58:18 +00:00
|
|
|
import pytest
|
|
|
|
|
2024-05-10 18:29:28 +00:00
|
|
|
from kasa import Module, SmartDevice
|
2024-05-07 18:58:18 +00:00
|
|
|
from kasa.tests.device_fixtures import parametrize
|
|
|
|
|
|
|
|
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),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
async def test_contact_features(dev: SmartDevice, feature, type):
|
|
|
|
"""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)
|