Files
python-kasa/tests/smart/modules/test_temperature.py
ZeliardM 88e1c27bd0
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
tests: add type annotations to Smart tests (#1686)
Add type annotations across all 'smart' tests, enabling mypy to check test function bodies, catching type errors that were previously hidden.
2026-07-08 00:11:59 +02:00

50 lines
1.4 KiB
Python

import pytest
from kasa import Module
from kasa.smart import SmartDevice
from ...device_fixtures import parametrize
temperature = parametrize(
"has temperature", component_filter="temperature", protocol_filter={"SMART.CHILD"}
)
temperature_warning = parametrize(
"has temperature warning",
component_filter="comfort_temperature",
protocol_filter={"SMART.CHILD"},
)
@temperature
@pytest.mark.parametrize(
("feature", "type"),
[
("temperature", float),
("temperature_unit", str),
],
)
async def test_temperature_features(dev: SmartDevice, feature: str, type: type) -> None:
"""Test that features are registered and work as expected."""
temp_module = dev.modules[Module.TemperatureSensor]
prop = getattr(temp_module, feature)
assert isinstance(prop, type)
feat = dev.features[feature]
assert feat.value == prop
assert isinstance(feat.value, type)
@temperature_warning
async def test_temperature_warning(dev: SmartDevice) -> None:
"""Test that features are registered and work as expected."""
temp_module = dev.modules[Module.TemperatureSensor]
assert hasattr(temp_module, "temperature_warning")
assert isinstance(temp_module.temperature_warning, bool)
feat = dev.features["temperature_warning"]
assert feat.value == temp_module.temperature_warning
assert isinstance(feat.value, bool)