mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-09 20:24:02 +00:00
Update cli modify presets to support smart devices (#1295)
This commit is contained in:
@@ -34,6 +34,8 @@ from kasa.cli.light import (
|
||||
brightness,
|
||||
effect,
|
||||
hsv,
|
||||
presets,
|
||||
presets_modify,
|
||||
temperature,
|
||||
)
|
||||
from kasa.cli.main import TYPES, _legacy_type_to_class, cli, cmd_command, raw_command
|
||||
@@ -575,6 +577,50 @@ async def test_light_effect(dev: Device, runner: CliRunner):
|
||||
assert res.exit_code == 2
|
||||
|
||||
|
||||
async def test_light_preset(dev: Device, runner: CliRunner):
|
||||
res = await runner.invoke(presets, obj=dev)
|
||||
if not (light_preset := dev.modules.get(Module.LightPreset)):
|
||||
assert "Device does not support light presets" in res.output
|
||||
return
|
||||
|
||||
if len(light_preset.preset_states_list) == 0:
|
||||
pytest.skip(
|
||||
"Some fixtures do not have presets and"
|
||||
" the api doesn'tsupport creating them"
|
||||
)
|
||||
# Start off with a known state
|
||||
first_name = light_preset.preset_list[1]
|
||||
await light_preset.set_preset(first_name)
|
||||
await dev.update()
|
||||
assert light_preset.preset == first_name
|
||||
|
||||
res = await runner.invoke(presets, obj=dev)
|
||||
assert "Brightness" in res.output
|
||||
assert res.exit_code == 0
|
||||
|
||||
res = await runner.invoke(
|
||||
presets_modify,
|
||||
[
|
||||
"0",
|
||||
"--brightness",
|
||||
"12",
|
||||
],
|
||||
obj=dev,
|
||||
)
|
||||
await dev.update()
|
||||
assert light_preset.preset_states_list[0].brightness == 12
|
||||
|
||||
res = await runner.invoke(
|
||||
presets_modify,
|
||||
[
|
||||
"0",
|
||||
],
|
||||
obj=dev,
|
||||
)
|
||||
await dev.update()
|
||||
assert "Need to supply at least one option to modify." in res.output
|
||||
|
||||
|
||||
async def test_led(dev: Device, runner: CliRunner):
|
||||
res = await runner.invoke(led, obj=dev)
|
||||
if not (led_module := dev.modules.get(Module.Led)):
|
||||
|
Reference in New Issue
Block a user