1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-24 12:29:08 +00:00

Improve device selection and show device by id if available (#2476)

This commit is contained in:
Pascal Vizeli
2021-01-28 15:43:06 +01:00
committed by GitHub
parent 6a0206c1e7
commit e024c3e38d
2 changed files with 55 additions and 3 deletions

View File

@@ -174,7 +174,7 @@ def test_ui_group_schema(coresys):
]
def test_ui_group_list(coresys):
def test_ui_group_list_schema(coresys):
"""Test with group schema."""
assert UiOptions(coresys)(
{
@@ -201,3 +201,54 @@ def test_ui_group_list(coresys):
"type": "schema",
},
]
def test_ui_simple_device_schema(coresys):
"""Test with simple schema."""
for device in (
Device(
"ttyACM0",
Path("/dev/ttyACM0"),
Path("/sys/bus/usb/002"),
"tty",
[],
{"ID_VENDOR": "xy"},
),
Device(
"ttyUSB0",
Path("/dev/ttyUSB0"),
Path("/sys/bus/usb/001"),
"tty",
[Path("/dev/ttyS1"), Path("/dev/serial/by-id/xyx")],
{"ID_VENDOR": "xy"},
),
Device("ttyS0", Path("/dev/ttyS0"), Path("/sys/bus/usb/003"), "tty", [], {}),
Device(
"video1",
Path("/dev/video1"),
Path("/sys/bus/usb/004"),
"misc",
[],
{"ID_VENDOR": "xy"},
),
):
coresys.hardware.update_device(device)
data = UiOptions(coresys)(
{
"name": "str",
"password": "password",
"fires": "bool",
"alias": "str?",
"input": "device(subsystem=tty)",
},
)
assert sorted(data[-1]["options"]) == sorted(
[
"/dev/serial/by-id/xyx",
"/dev/ttyACM0",
"/dev/ttyS0",
]
)
assert data[-1]["type"] == "select"