mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-09 02:49:43 +00:00
Return list of possible data disk targets (#3133)
* Return list of possible data disk targets * fix path * fix tests * Add test * Fix tests * Add tests * Add more tests * Remove debug * Address comments * more clear
This commit is contained in:
64
tests/os/test_data_disk.py
Normal file
64
tests/os/test_data_disk.py
Normal file
@@ -0,0 +1,64 @@
|
||||
"""Test OS API."""
|
||||
from pathlib import Path, PosixPath
|
||||
|
||||
import pytest
|
||||
|
||||
from supervisor.coresys import CoreSys
|
||||
from supervisor.exceptions import HassOSDataDiskError
|
||||
from supervisor.hardware.data import Device
|
||||
|
||||
# pylint: disable=protected-access
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def tests_datadisk_current(coresys: CoreSys):
|
||||
"""Test current datadisk."""
|
||||
await coresys.dbus.agent.connect()
|
||||
await coresys.dbus.agent.update()
|
||||
|
||||
assert coresys.os.datadisk.disk_used == PosixPath("/dev/sda")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_datadisk_move(coresys: CoreSys):
|
||||
"""Test datadisk moved without exists device."""
|
||||
await coresys.dbus.agent.connect()
|
||||
await coresys.dbus.agent.update()
|
||||
coresys.os._available = True
|
||||
|
||||
with pytest.raises(HassOSDataDiskError):
|
||||
await coresys.os.datadisk.migrate_disk(Path("/dev/sdaaaa"))
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_datadisk_list(coresys: CoreSys):
|
||||
"""Test docker info api."""
|
||||
await coresys.dbus.agent.connect()
|
||||
await coresys.dbus.agent.update()
|
||||
|
||||
coresys.hardware.update_device(
|
||||
Device(
|
||||
"sda",
|
||||
Path("/dev/sda"),
|
||||
Path("/sys/bus/usb/000"),
|
||||
"block",
|
||||
None,
|
||||
[Path("/dev/serial/by-id/test")],
|
||||
{"ID_NAME": "xy", "MINOR": "0", "DEVTYPE": "disk"},
|
||||
[],
|
||||
)
|
||||
)
|
||||
coresys.hardware.update_device(
|
||||
Device(
|
||||
"sda1",
|
||||
Path("/dev/sda1"),
|
||||
Path("/sys/bus/usb/000/1"),
|
||||
"block",
|
||||
None,
|
||||
[Path("/dev/serial/by-id/test1")],
|
||||
{"ID_NAME": "xy", "MINOR": "1", "DEVTYPE": "partition"},
|
||||
[],
|
||||
)
|
||||
)
|
||||
|
||||
assert coresys.os.datadisk.available_disks == [PosixPath("/dev/sda")]
|
||||
Reference in New Issue
Block a user