mirror of
https://github.com/python-kasa/python-kasa.git
synced 2026-07-11 09:52:04 +00:00
Some checks failed
CI / Perform Lint Checks (3.14) (push) Has been cancelled
CodeQL Checks / Analyze (python) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.14 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.14 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
CI / Python 3.14 on windows-latest (push) Has been cancelled
Stale / stale (push) Has been cancelled
Add type annotations across all 'smart' tests, enabling mypy to check test function bodies, catching type errors that were previously hidden.
47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
import pytest
|
|
|
|
from kasa import Module
|
|
from kasa.smart import SmartDevice
|
|
|
|
from ...device_fixtures import parametrize
|
|
|
|
child_protection = parametrize(
|
|
"has child protection",
|
|
component_filter="child_protection",
|
|
protocol_filter={"SMART.CHILD"},
|
|
)
|
|
|
|
|
|
@child_protection
|
|
@pytest.mark.parametrize(
|
|
("feature", "prop_name", "type"),
|
|
[
|
|
("child_lock", "enabled", bool),
|
|
],
|
|
)
|
|
async def test_features(
|
|
dev: SmartDevice, feature: str, prop_name: str, type: type
|
|
) -> None:
|
|
"""Test that features are registered and work as expected."""
|
|
protect = dev.modules[Module.ChildProtection]
|
|
assert protect is not None
|
|
|
|
prop = getattr(protect, prop_name)
|
|
assert isinstance(prop, type)
|
|
|
|
feat = protect._device.features[feature]
|
|
assert feat.value == prop
|
|
assert isinstance(feat.value, type)
|
|
|
|
|
|
@child_protection
|
|
async def test_enabled(dev: SmartDevice) -> None:
|
|
"""Test the API."""
|
|
protect = dev.modules[Module.ChildProtection]
|
|
assert protect is not None
|
|
|
|
assert isinstance(protect.enabled, bool)
|
|
await protect.set_enabled(False)
|
|
await dev.update()
|
|
assert protect.enabled is False
|