Add double click module for smart buttons

This commit is contained in:
Steven B
2025-01-07 12:53:10 +00:00
parent 7b3dde9aa0
commit cb972c3a30
6 changed files with 100 additions and 4 deletions

View File

@@ -167,6 +167,12 @@ class FakeSmartTransport(BaseTransport):
"setup_payload": "00:0000000-0000.00.000",
},
),
"get_double_click_info": (
"double_click",
{
"enable": False,
},
),
}
async def send(self, request: str):

View File

@@ -0,0 +1,43 @@
"""Tests for smart double click module."""
from __future__ import annotations
from kasa import Device
from kasa.smartcam.smartcammodule import SmartModule
from ...device_fixtures import parametrize
doubleclick = parametrize(
"has double click", component_filter="double_click", protocol_filter={"SMART.CHILD"}
)
@doubleclick
async def test_doubleclick(dev: Device):
"""Test device double click."""
doubleclick = dev.modules.get(SmartModule.SmartDoubleClick)
assert doubleclick
dc_feat = dev.features.get("double_click")
assert dc_feat
original_enabled = doubleclick.enabled
try:
await doubleclick.set_enabled(not original_enabled)
await dev.update()
assert doubleclick.enabled is not original_enabled
assert dc_feat.value is not original_enabled
await doubleclick.set_enabled(original_enabled)
await dev.update()
assert doubleclick.enabled is original_enabled
assert dc_feat.value is original_enabled
await dc_feat.set_value(not original_enabled)
await dev.update()
assert doubleclick.enabled is not original_enabled
assert dc_feat.value is not original_enabled
finally:
await doubleclick.set_enabled(original_enabled)