2024-11-13 16:10:06 +00:00
|
|
|
import pytest
|
|
|
|
|
2020-05-27 14:55:18 +00:00
|
|
|
from kasa import DeviceType
|
|
|
|
|
2024-03-15 15:55:48 +00:00
|
|
|
from .conftest import plug, plug_iot, plug_smart, switch_smart, wallswitch_iot
|
|
|
|
from .test_iotdevice import SYSINFO_SCHEMA
|
2024-01-29 19:26:39 +00:00
|
|
|
|
|
|
|
# these schemas should go to the mainlib as
|
|
|
|
# they can be useful when adding support for new features/devices
|
|
|
|
# as well as to check that faked devices are operating properly.
|
2020-05-27 14:55:18 +00:00
|
|
|
|
|
|
|
|
2024-03-01 18:32:45 +00:00
|
|
|
@plug_iot
|
2020-05-27 14:55:18 +00:00
|
|
|
async def test_plug_sysinfo(dev):
|
|
|
|
assert dev.sys_info is not None
|
2024-01-29 19:26:39 +00:00
|
|
|
SYSINFO_SCHEMA(dev.sys_info)
|
2020-05-27 14:55:18 +00:00
|
|
|
|
|
|
|
assert dev.model is not None
|
|
|
|
|
|
|
|
assert dev.device_type == DeviceType.Plug or dev.device_type == DeviceType.Strip
|
|
|
|
|
|
|
|
|
2024-03-01 18:32:45 +00:00
|
|
|
@wallswitch_iot
|
|
|
|
async def test_switch_sysinfo(dev):
|
|
|
|
assert dev.sys_info is not None
|
|
|
|
SYSINFO_SCHEMA(dev.sys_info)
|
|
|
|
|
|
|
|
assert dev.model is not None
|
|
|
|
|
|
|
|
assert dev.device_type == DeviceType.WallSwitch
|
|
|
|
|
|
|
|
|
|
|
|
@plug_iot
|
|
|
|
async def test_plug_led(dev):
|
2024-11-13 16:10:06 +00:00
|
|
|
with pytest.deprecated_call(match="use: Module.Led in device.modules instead"):
|
|
|
|
original = dev.led
|
2024-03-01 18:32:45 +00:00
|
|
|
|
2024-11-13 16:10:06 +00:00
|
|
|
await dev.set_led(False)
|
|
|
|
await dev.update()
|
|
|
|
assert not dev.led
|
2024-03-01 18:32:45 +00:00
|
|
|
|
2024-11-13 16:10:06 +00:00
|
|
|
await dev.set_led(True)
|
|
|
|
await dev.update()
|
|
|
|
assert dev.led
|
2024-03-01 18:32:45 +00:00
|
|
|
|
2024-11-13 16:10:06 +00:00
|
|
|
await dev.set_led(original)
|
2024-03-01 18:32:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
@wallswitch_iot
|
|
|
|
async def test_switch_led(dev):
|
2024-11-13 16:10:06 +00:00
|
|
|
with pytest.deprecated_call(match="use: Module.Led in device.modules instead"):
|
|
|
|
original = dev.led
|
2020-05-27 14:55:18 +00:00
|
|
|
|
2024-11-13 16:10:06 +00:00
|
|
|
await dev.set_led(False)
|
|
|
|
await dev.update()
|
|
|
|
assert not dev.led
|
2020-05-27 14:55:18 +00:00
|
|
|
|
2024-11-13 16:10:06 +00:00
|
|
|
await dev.set_led(True)
|
|
|
|
await dev.update()
|
|
|
|
assert dev.led
|
2020-05-27 14:55:18 +00:00
|
|
|
|
2024-11-13 16:10:06 +00:00
|
|
|
await dev.set_led(original)
|
2023-12-04 18:50:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
@plug_smart
|
|
|
|
async def test_plug_device_info(dev):
|
|
|
|
assert dev._info is not None
|
|
|
|
assert dev.model is not None
|
|
|
|
|
|
|
|
assert dev.device_type == DeviceType.Plug or dev.device_type == DeviceType.Strip
|
2024-03-01 18:32:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
@switch_smart
|
|
|
|
async def test_switch_device_info(dev):
|
|
|
|
assert dev._info is not None
|
|
|
|
assert dev.model is not None
|
|
|
|
|
|
|
|
assert (
|
|
|
|
dev.device_type == DeviceType.WallSwitch or dev.device_type == DeviceType.Dimmer
|
|
|
|
)
|
2024-03-15 15:55:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
@plug
|
|
|
|
def test_device_type_plug(dev):
|
|
|
|
assert dev.device_type == DeviceType.Plug
|