mirror of
https://github.com/python-kasa/python-kasa.git
synced 2026-07-08 14:52:03 +00:00
Add type annotations to all test functions across 8 files in `tests/iot/`, improving type safety and enabling mypy to check function bodies.
50 lines
1.3 KiB
Python
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 == {}
|