FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

- Fix SmartCamWhiteLamp ModuleName key from 'whiteLamp' to 'WhiteLamp' · python-kasa/python-kasa@2c10b1e · GitHub

Repository navigation

Commit 2c10b1e

Browse files
Ingrid Jardillier
committed
- Fix SmartCamWhiteLamp ModuleName key from 'whiteLamp' to 'WhiteLamp'
to match the class name used as key in dev.modules - Add SmartCamModule.SmartCamWhiteLamp assertion in test_whitelamp_is_on - Add test_whitelamp_no_brightness to cover the case where brightness is not supported by the device"
1 parent 5aa40ed commit 2c10b1e

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎kasa/smartcam/smartcammodule.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class SmartCamModule(SmartModule):
5858
"devicemodule"
5959
)
6060

61-
SmartCamWhiteLamp: Final[ModuleName[modules.WhiteLamp]] = ModuleName("whiteLamp")
61+
SmartCamWhiteLamp: Final[ModuleName[modules.WhiteLamp]] = ModuleName("WhiteLamp")
6262

6363
#: Module name to be queried
6464
QUERY_MODULE_NAME: str

‎tests/smartcam/modules/test_whitelamp.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pytest
66

77
from kasa import Device, Module
8+
from kasa.smartcam.smartcammodule import SmartCamModule
89

910
from ...device_fixtures import parametrize
1011

@@ -18,6 +19,7 @@ async def test_whitelamp_is_on(dev: Device):
1819
"""Test white lamp on/off state reflects fixture data."""
1920
whitelamp = dev.modules.get(Module.WhiteLamp)
2021
assert whitelamp is not None
22+
assert dev.modules.get(SmartCamModule.SmartCamWhiteLamp) is whitelamp
2123

2224
assert isinstance(whitelamp.is_on, bool)
2325

@@ -83,6 +85,20 @@ async def test_whitelamp_brightness(dev: Device):
8385
await dev.update()
8486

8587

88+
@whitelamp_smartcam
89+
async def test_whitelamp_no_brightness(dev: Device):
90+
"""Test that brightness feature is absent when device does not support it."""
91+
whitelamp = dev.modules.get(Module.WhiteLamp)
92+
assert whitelamp is not None
93+
94+
config = whitelamp.data["getWhitelampConfig"]["image"]["switch"]
95+
if "wtl_intensity_level" not in config:
96+
assert not whitelamp.has_feature("brightness")
97+
assert "white_lamp_brightness" not in dev.features
98+
else:
99+
pytest.skip("Device supports brightness, skipping no-brightness test")
100+
101+
86102
@whitelamp_smartcam
87103
async def test_whitelamp_features(dev: Device):
88104
"""Test white lamp features are registered on the device."""

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL