python-kasa/kasa/tests/test_feature_brightness.py
Teemu R 0d5a3c8439
Add brightness module (#806)
Add module for controlling the brightness.
2024-03-05 15:41:40 +01:00

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)