Files
python-kasa/tests/iot/test_iotstrip.py
ZeliardM da2588291d tests: add type annotations to IoT tests (#1685)
Add type annotations to all test functions across 8 files in `tests/iot/`, improving type safety and enabling mypy to check function bodies.
2026-07-05 18:31:48 +02:00

50 lines
1.3 KiB
Python

from unittest.mock import AsyncMock
from pytest_mock import MockerFixture
from kasa import Module
from kasa.iot import IotStrip
from kasa.iot.iotstrip import IotStripPlug
from tests.conftest import strip_emeter_iot, strip_iot
@strip_iot
async def test_strip_update_and_child_update_behaviors(dev: IotStrip) -> None:
await dev.update()
await dev.update(update_children=False)
assert dev.children, "Expected strip device to have children"
child = dev.children[0]
await child.update(update_children=False)
assert getattr(child, "_features", None)
@strip_iot
async def test_strip_child_delegated_properties(dev: IotStrip) -> None:
await dev.update()
child = dev.children[0]
assert isinstance(child, IotStripPlug)
assert child.led is False
assert child.time == dev.time
assert child.timezone == dev.timezone
na = child.next_action
assert isinstance(na, dict)
assert "type" in na
@strip_emeter_iot
async def test_strip_emeter_erase_stats(dev: IotStrip, mocker: MockerFixture) -> None:
await dev.update()
for child in dev.children:
energy = child.modules.get(Module.Energy)
if energy:
mocker.patch.object(energy, "erase_stats", AsyncMock(return_value={}))
res = await dev.modules[Module.Energy].erase_stats()
assert res == {}