mirror of
https://github.com/home-assistant/supervisor.git
synced 2026-08-21 13:49:01 +01:00
* Fix typos in comments, docstrings and log messages Correct 39 spelling mistakes across comments, docstrings and log/error message strings throughout the package (e.g. "conection" -> "connection", "Incomming" -> "Incoming", "Rasie" -> "Raise"). All changes are confined to human-readable text; no identifiers, attributes or D-Bus contracts are touched, so there is no behavior change. Found with codespell. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix typos in tests and CI workflow Correct spelling mistakes in test comments, docstrings and data, plus one in the builder workflow, so the whole tree is clean for the codespell hook added next. The assertion in test_network_manager.py is updated to match the corrected "Unknown error while processing" log message in the source. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Add codespell pre-commit hook Wire up codespell so spelling mistakes in comments, docstrings and strings are caught automatically. The vendored frontend panel is excluded, and "hass" and "astroid" are added to the ignore list as known false positives (the Home Assistant abbreviation and the pylint dependency package). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Address review feedback Improve grammar in several of the touched comments and docstrings: use the plural "ignore conditions" for the list-returning property, add the missing auxiliary verb and fix agreement in the timezone-filter comment, fix "backups ... use" agreement, and reword "underlay" to "underlying" in the arch module docstring. Also drop the "*.json" skip from the codespell hook. It was carried over from another project but is unnecessary here (all tracked JSON is clean), and skipping it would needlessly leave translation and data JSON unchecked. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Reword onboarding comment "overflight" was a literal calque of the German "überflogen"; use the idiomatic "skimmed through" instead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
100 lines
2.5 KiB
Python
100 lines
2.5 KiB
Python
"""Test hardware utils."""
|
|
|
|
import errno
|
|
from pathlib import Path
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
import pytest
|
|
|
|
from supervisor.coresys import CoreSys
|
|
from supervisor.hardware.data import Device
|
|
|
|
|
|
def test_have_audio(coresys: CoreSys):
|
|
"""Test usb device filter."""
|
|
assert not coresys.hardware.helper.support_audio
|
|
|
|
coresys.hardware.update_device(
|
|
Device(
|
|
"sda",
|
|
Path("/dev/sda"),
|
|
Path("/sys/bus/usb/000"),
|
|
"sound",
|
|
None,
|
|
[],
|
|
{"ID_NAME": "xy"},
|
|
[],
|
|
)
|
|
)
|
|
|
|
assert coresys.hardware.helper.support_audio
|
|
|
|
|
|
def test_have_usb(coresys: CoreSys):
|
|
"""Test usb device filter."""
|
|
assert not coresys.hardware.helper.support_usb
|
|
|
|
coresys.hardware.update_device(
|
|
Device(
|
|
"sda",
|
|
Path("/dev/sda"),
|
|
Path("/sys/bus/usb/000"),
|
|
"usb",
|
|
None,
|
|
[],
|
|
{"ID_NAME": "xy"},
|
|
[],
|
|
)
|
|
)
|
|
|
|
assert coresys.hardware.helper.support_usb
|
|
|
|
|
|
def test_have_gpio(coresys: CoreSys):
|
|
"""Test usb device filter."""
|
|
assert not coresys.hardware.helper.support_gpio
|
|
|
|
coresys.hardware.update_device(
|
|
Device(
|
|
"sda",
|
|
Path("/dev/sda"),
|
|
Path("/sys/bus/usb/000"),
|
|
"gpio",
|
|
None,
|
|
[],
|
|
{"ID_NAME": "xy"},
|
|
[],
|
|
)
|
|
)
|
|
|
|
assert coresys.hardware.helper.support_gpio
|
|
|
|
|
|
def test_hide_virtual_device(coresys: CoreSys):
|
|
"""Test hiding virtual devices."""
|
|
udev_device = MagicMock()
|
|
|
|
udev_device.sys_path = "/sys/devices/platform/test"
|
|
assert not coresys.hardware.helper.hide_virtual_device(udev_device)
|
|
|
|
udev_device.sys_path = "/sys/devices/virtual/block/test"
|
|
assert coresys.hardware.helper.hide_virtual_device(udev_device)
|
|
|
|
udev_device.sys_path = "/sys/devices/virtual/tty/tty1"
|
|
assert coresys.hardware.helper.hide_virtual_device(udev_device)
|
|
|
|
udev_device.sys_path = "/sys/devices/virtual/vc/vcs1"
|
|
assert coresys.hardware.helper.hide_virtual_device(udev_device)
|
|
|
|
|
|
async def test_last_boot_error(coresys: CoreSys, caplog: pytest.LogCaptureFixture):
|
|
"""Test error reading last boot."""
|
|
with patch(
|
|
"supervisor.hardware.helper.Path.read_text", side_effect=(err := OSError())
|
|
):
|
|
err.errno = errno.EBADMSG
|
|
assert await coresys.hardware.helper.last_boot() is None
|
|
|
|
assert coresys.core.healthy is True
|
|
assert "Can't read stat data" in caplog.text
|