1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2026-05-19 14:18:53 +01:00
Files
supervisor/tests/api/test_hardware.py
T
Stefan Agner f8dbafe0bb Drop redundant @pytest.mark.asyncio decorators (#6795)
The pytest config sets ``asyncio_mode = "auto"``, which already
auto-marks every ``async def test_*`` as a coroutine test. The 38
``@pytest.mark.asyncio`` decorators sprinkled across the suite were
no-ops kept around from before that flag was set. Remove them along
with the now-unused ``import pytest`` lines they were the only
consumer of.

Pure mechanical cleanup; no test behavior changes.
2026-05-04 14:48:18 +02:00

70 lines
2.0 KiB
Python

"""Test Docker API."""
from pathlib import Path
from aiohttp.test_utils import TestClient
from supervisor.coresys import CoreSys
from supervisor.hardware.data import Device
async def test_api_hardware_info(api_client_with_prefix: tuple[TestClient, str]):
"""Test docker info api."""
api_client, prefix = api_client_with_prefix
resp = await api_client.get(f"{prefix}/hardware/info")
result = await resp.json()
assert result["result"] == "ok"
async def test_api_hardware_info_device(
api_client_with_prefix: tuple[TestClient, str], coresys: CoreSys
):
"""Test docker info api."""
api_client, prefix = api_client_with_prefix
coresys.hardware.update_device(
Device(
"sda",
Path("/dev/sda"),
Path("/sys/bus/usb/000"),
"sound",
None,
[Path("/dev/serial/by-id/test")],
{"ID_NAME": "xy"},
[],
)
)
resp = await api_client.get(f"{prefix}/hardware/info")
result = await resp.json()
assert result["result"] == "ok"
assert result["data"]["devices"][-1]["name"] == "sda"
assert result["data"]["devices"][-1]["by_id"] == "/dev/serial/by-id/test"
async def test_api_hardware_info_drives(
api_client_with_prefix: tuple[TestClient, str], coresys: CoreSys
):
"""Test drive info."""
api_client, prefix = api_client_with_prefix
await coresys.dbus.udisks2.connect(coresys.dbus.bus)
resp = await api_client.get(f"{prefix}/hardware/info")
result = await resp.json()
assert result["result"] == "ok"
assert {
drive["id"]: {fs["id"] for fs in drive["filesystems"]}
for drive in result["data"]["drives"]
} == {
"BJTD4R-0x97cde291": {
"by-id-mmc-BJTD4R_0x97cde291-part1",
"by-id-mmc-BJTD4R_0x97cde291-part3",
},
"SSK-SSK-Storage-DF56419883D56": {
"by-id-usb-SSK_SSK_Storage_DF56419883D56-0:0-part1"
},
"Generic-Flash-Disk-61BCDDB6": {"by-uuid-2802-1EDE"},
}