mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-22 00:26:29 +00:00
Extend video & add tests (#1518)
This commit is contained in:
parent
a21353909d
commit
8dbfea75b1
@ -28,7 +28,7 @@ GPIO_DEVICES: Path = Path("/sys/class/gpio")
|
|||||||
SOC_DEVICES: Path = Path("/sys/devices/platform/soc")
|
SOC_DEVICES: Path = Path("/sys/devices/platform/soc")
|
||||||
RE_TTY: re.Pattern = re.compile(r"tty[A-Z]+")
|
RE_TTY: re.Pattern = re.compile(r"tty[A-Z]+")
|
||||||
|
|
||||||
RE_VIDEO_DEVICES = re.compile(r"^(?:vchiq|cec)")
|
RE_VIDEO_DEVICES = re.compile(r"^(?:vchiq|cec\d+|video\d+)")
|
||||||
|
|
||||||
|
|
||||||
@attr.s(frozen=True)
|
@attr.s(frozen=True)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
"""Test hardware utils."""
|
"""Test hardware utils."""
|
||||||
|
from unittest.mock import patch, PropertyMock
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from hassio.misc.hardware import Hardware
|
from hassio.misc.hardware import Hardware, Device
|
||||||
|
|
||||||
|
|
||||||
def test_read_all_devices():
|
def test_read_all_devices():
|
||||||
@ -8,3 +10,25 @@ def test_read_all_devices():
|
|||||||
system = Hardware()
|
system = Hardware()
|
||||||
|
|
||||||
assert system.devices
|
assert system.devices
|
||||||
|
|
||||||
|
|
||||||
|
def test_video_devices():
|
||||||
|
"""Test video device filter."""
|
||||||
|
system = Hardware()
|
||||||
|
device_list = [
|
||||||
|
Device("test-dev", Path("/dev/test-dev"), []),
|
||||||
|
Device("vchiq", Path("/dev/vchiq"), []),
|
||||||
|
Device("cec0", Path("/dev/cec0"), []),
|
||||||
|
Device("video1", Path("/dev/video1"), []),
|
||||||
|
]
|
||||||
|
|
||||||
|
with patch(
|
||||||
|
"hassio.misc.hardware.Hardware.devices", new_callable=PropertyMock
|
||||||
|
) as mock_device:
|
||||||
|
mock_device.return_value = device_list
|
||||||
|
|
||||||
|
assert system.video_devices == [
|
||||||
|
Device("vchiq", Path("/dev/vchiq"), []),
|
||||||
|
Device("cec0", Path("/dev/cec0"), []),
|
||||||
|
Device("video1", Path("/dev/video1"), []),
|
||||||
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user