Skip to content

Commit 691bf7b

Browse files
committed
test(light): cover brightness-only non-zero range
1 parent 179177e commit 691bf7b

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tests/test_light.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,33 @@ async def test_async_turn_on_brightness_only_zero_range_write_uses_first_on_valu
376376
mock_device.async_set_properties.assert_called_once_with({assert_dp: expected_dps})
377377

378378

379+
@pytest.mark.asyncio
380+
async def test_async_turn_on_brightness_only_non_zero_range_write_keeps_range_min():
381+
"""Brightness-only non-zero ranges should not use the zero-off adjustment."""
382+
mock_device = AsyncMock()
383+
mock_device.get_property = Mock()
384+
device_dps = {"1": 10}
385+
mock_device.get_property.side_effect = lambda arg: device_dps[arg]
386+
mock_config = Mock()
387+
config = TuyaEntityConfig(
388+
mock_config,
389+
{
390+
"entity": "light",
391+
"dps": [
392+
{
393+
"id": "1",
394+
"name": "brightness",
395+
"type": "integer",
396+
"range": {"min": 10, "max": 1000},
397+
},
398+
],
399+
},
400+
)
401+
light = TuyaLocalLight(mock_device, config)
402+
await light.async_turn_on(brightness=1)
403+
mock_device.async_set_properties.assert_called_once_with({"1": 10})
404+
405+
379406
@pytest.mark.parametrize(
380407
("brightness_range", "mapping", "expected_dps"),
381408
[

0 commit comments

Comments
 (0)