mirror of
https://github.com/python-kasa/python-kasa.git
synced 2026-07-08 06:41:59 +00:00
tests: add type annotations to Smart tests (#1686)
Some checks are pending
CI / Perform Lint Checks (3.14) (push) Waiting to run
CI / Python 3.11 on macos-latest (push) Blocked by required conditions
CI / Python 3.12 on macos-latest (push) Blocked by required conditions
CI / Python 3.13 on macos-latest (push) Blocked by required conditions
CI / Python 3.14 on macos-latest (push) Blocked by required conditions
CI / Python 3.11 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.12 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.13 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.14 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.11 on windows-latest (push) Blocked by required conditions
CI / Python 3.12 on windows-latest (push) Blocked by required conditions
CI / Python 3.13 on windows-latest (push) Blocked by required conditions
CI / Python 3.14 on windows-latest (push) Blocked by required conditions
CodeQL Checks / Analyze (python) (push) Waiting to run
Some checks are pending
CI / Perform Lint Checks (3.14) (push) Waiting to run
CI / Python 3.11 on macos-latest (push) Blocked by required conditions
CI / Python 3.12 on macos-latest (push) Blocked by required conditions
CI / Python 3.13 on macos-latest (push) Blocked by required conditions
CI / Python 3.14 on macos-latest (push) Blocked by required conditions
CI / Python 3.11 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.12 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.13 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.14 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.11 on windows-latest (push) Blocked by required conditions
CI / Python 3.12 on windows-latest (push) Blocked by required conditions
CI / Python 3.13 on windows-latest (push) Blocked by required conditions
CI / Python 3.14 on windows-latest (push) Blocked by required conditions
CodeQL Checks / Analyze (python) (push) Waiting to run
Add type annotations across all 'smart' tests, enabling mypy to check test function bodies, catching type errors that were previously hidden.
This commit is contained in:
@@ -3,7 +3,8 @@ from enum import Enum
|
||||
|
||||
import pytest
|
||||
|
||||
from kasa.smart.modules import WaterleakSensor
|
||||
from kasa import Module
|
||||
from kasa.smart import SmartDevice
|
||||
|
||||
from ...conftest import get_device_for_fixture_protocol
|
||||
from ...device_fixtures import parametrize
|
||||
@@ -28,10 +29,12 @@ async def parent(request):
|
||||
("water_leak", "status", Enum),
|
||||
],
|
||||
)
|
||||
async def test_waterleak_properties(dev, parent, feature, prop_name, type):
|
||||
async def test_waterleak_properties(
|
||||
dev: SmartDevice, parent: SmartDevice, feature: str, prop_name: str, type: type
|
||||
) -> None:
|
||||
"""Test that features are registered and work as expected."""
|
||||
dev._parent = parent
|
||||
waterleak: WaterleakSensor = dev.modules["WaterleakSensor"]
|
||||
waterleak = dev.modules[Module.WaterleakSensor]
|
||||
|
||||
prop = getattr(waterleak, prop_name)
|
||||
assert isinstance(prop, type)
|
||||
@@ -42,10 +45,10 @@ async def test_waterleak_properties(dev, parent, feature, prop_name, type):
|
||||
|
||||
|
||||
@waterleak
|
||||
async def test_waterleak_features(dev, parent):
|
||||
async def test_waterleak_features(dev: SmartDevice, parent: SmartDevice) -> None:
|
||||
"""Test waterleak features."""
|
||||
dev._parent = parent
|
||||
waterleak: WaterleakSensor = dev.modules["WaterleakSensor"]
|
||||
waterleak = dev.modules[Module.WaterleakSensor]
|
||||
|
||||
assert "water_leak" in dev.features
|
||||
assert dev.features["water_leak"].value == waterleak.status
|
||||
|
||||
Reference in New Issue
Block a user