mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-01-09 06:17:08 +00:00
0d5a3c8439
Add module for controlling the brightness.
29 lines
812 B
Python
29 lines
812 B
Python
import pytest
|
|
|
|
from kasa.smart import SmartDevice
|
|
from kasa.tests.conftest import parametrize
|
|
|
|
brightness = parametrize("brightness smart", component_filter="brightness")
|
|
|
|
|
|
@brightness
|
|
async def test_brightness_component(dev: SmartDevice):
|
|
"""Test brightness feature."""
|
|
assert isinstance(dev, SmartDevice)
|
|
assert "brightness" in dev._components
|
|
|
|
# Test getting the value
|
|
feature = dev.features["brightness"]
|
|
assert isinstance(feature.value, int)
|
|
assert feature.value > 0 and feature.value <= 100
|
|
|
|
# Test setting the value
|
|
await feature.set_value(10)
|
|
assert feature.value == 10
|
|
|
|
with pytest.raises(ValueError):
|
|
await feature.set_value(feature.minimum_value - 10)
|
|
|
|
with pytest.raises(ValueError):
|
|
await feature.set_value(feature.maximum_value + 10)
|