Do not expose child modules on parent devices (#964)

Removes the logic to expose child modules on parent devices,
which could cause complications with downstream consumers unknowingly duplicating things.
This commit is contained in:
Steven B
2024-06-10 05:59:37 +01:00
committed by GitHub
parent b094e334ca
commit fe0bbf1b98
6 changed files with 34 additions and 38 deletions

View File

@@ -3,7 +3,7 @@ from pytest_mock import MockerFixture
from kasa import Module
from kasa.smart import SmartDevice
from kasa.tests.device_fixtures import parametrize
from kasa.tests.device_fixtures import get_parent_and_child_modules, parametrize
fan = parametrize("has fan", component_filter="fan_control", protocol_filter={"SMART"})
@@ -11,10 +11,9 @@ fan = parametrize("has fan", component_filter="fan_control", protocol_filter={"S
@fan
async def test_fan_speed(dev: SmartDevice, mocker: MockerFixture):
"""Test fan speed feature."""
fan = dev.modules.get(Module.Fan)
fan = next(get_parent_and_child_modules(dev, Module.Fan))
assert fan
level_feature = dev.features["fan_speed_level"]
level_feature = fan._module_features["fan_speed_level"]
assert (
level_feature.minimum_value
<= level_feature.value
@@ -36,9 +35,9 @@ async def test_fan_speed(dev: SmartDevice, mocker: MockerFixture):
@fan
async def test_sleep_mode(dev: SmartDevice, mocker: MockerFixture):
"""Test sleep mode feature."""
fan = dev.modules.get(Module.Fan)
fan = next(get_parent_and_child_modules(dev, Module.Fan))
assert fan
sleep_feature = dev.features["fan_sleep_mode"]
sleep_feature = fan._module_features["fan_sleep_mode"]
assert isinstance(sleep_feature.value, bool)
call = mocker.spy(fan, "call")
@@ -55,7 +54,7 @@ async def test_sleep_mode(dev: SmartDevice, mocker: MockerFixture):
async def test_fan_module(dev: SmartDevice, mocker: MockerFixture):
"""Test fan speed on device interface."""
assert isinstance(dev, SmartDevice)
fan = dev.modules.get(Module.Fan)
fan = next(get_parent_and_child_modules(dev, Module.Fan))
assert fan
device = fan._device