1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-24 12:29:08 +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:
Pascal Vizeli
2021-09-21 14:51:58 +02:00
committed by GitHub
parent 4f97013df4
commit 04f36e92e1
19 changed files with 332 additions and 50 deletions

View File

@@ -3,32 +3,51 @@
from pathlib import Path
from unittest.mock import patch
from supervisor.coresys import CoreSys
from supervisor.hardware.data import Device
def test_system_partition(coresys):
"""Test if it is a system partition."""
def test_system_partition_disk(coresys: CoreSys):
"""Test if it is a system disk/partition."""
disk = Device(
"sda0",
Path("/dev/sda0"),
"sda1",
Path("/dev/sda1"),
Path("/sys/bus/usb/001"),
"block",
None,
[],
{"MAJOR": "5", "MINOR": "10"},
[],
)
assert not coresys.hardware.disk.is_system_partition(disk)
assert not coresys.hardware.disk.is_used_by_system(disk)
disk = Device(
"sda0",
Path("/dev/sda0"),
"sda1",
Path("/dev/sda1"),
Path("/sys/bus/usb/001"),
"block",
None,
[],
{"MAJOR": "5", "MINOR": "10", "ID_FS_LABEL": "hassos-overlay"},
[],
)
assert coresys.hardware.disk.is_system_partition(disk)
assert coresys.hardware.disk.is_used_by_system(disk)
coresys.hardware.update_device(disk)
disk_root = Device(
"sda",
Path("/dev/sda"),
Path("/sys/bus/usb/001"),
"block",
None,
[],
{"MAJOR": "5", "MINOR": "0"},
[Path("/dev/sda1")],
)
assert coresys.hardware.disk.is_used_by_system(disk_root)
def test_free_space(coresys):