Three things are broken on origin/main as of 6114cb2, all found in one
red CI run:
- build-iso workflow couldn't reach docker. forgejo-runner's config
sets `docker_host: tcp://docker-in-docker:2375` but that env doesn't
propagate into job containers on `runs-on: ubuntu-latest`, and the
default job image has no docker CLI. Fix: pin `DOCKER_HOST` on the
job and apt-install `docker.io` before invoking `iso/build.sh`.
- Two tests asserted on the pre-4.x archinstall schema:
`creds["root_password"]` (now `!root-password`) and
`cfg["disk_config"]["device"]` / `cfg["users"]` (users moved to
creds; disk_config is now a full `default_layout` dict). Rewrote
the tests to reflect 4.x reality and monkeypatched `build_disk_config`
since its real body imports archinstall, which isn't on CI.
- Ruff flagged one line of `PROGRESS_PHASES` at 107 chars — collapsed
the column alignment. `ruff format` pulled in a couple of cosmetic
expansions in spawn_archinstall and the tests that had been drifting.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
72 lines
1.8 KiB
Python
72 lines
1.8 KiB
Python
from drives import (
|
|
get_drive_type_score,
|
|
get_size_score,
|
|
parse_lsblk_output,
|
|
parse_size_gb,
|
|
score_device,
|
|
)
|
|
|
|
|
|
def test_parse_size_gb_terabytes():
|
|
assert parse_size_gb("1T") == 1024.0
|
|
|
|
|
|
def test_parse_size_gb_gigabytes():
|
|
assert parse_size_gb("500G") == 500.0
|
|
|
|
|
|
def test_parse_size_gb_megabytes():
|
|
assert parse_size_gb("2048M") == 2.0
|
|
|
|
|
|
def test_parse_size_gb_european_comma_decimal():
|
|
assert parse_size_gb("1,5T") == 1.5 * 1024
|
|
|
|
|
|
def test_parse_size_gb_empty_returns_none():
|
|
assert parse_size_gb("") is None
|
|
|
|
|
|
def test_parse_size_gb_unknown_unit_returns_none():
|
|
assert parse_size_gb("500K") is None
|
|
|
|
|
|
def test_drive_type_score_nvme():
|
|
assert get_drive_type_score("/dev/nvme0n1") == 15
|
|
|
|
|
|
def test_drive_type_score_ssd():
|
|
assert get_drive_type_score("/dev/ssd0") == 10
|
|
|
|
|
|
def test_drive_type_score_hdd_fallback():
|
|
assert get_drive_type_score("/dev/sda") == 5
|
|
|
|
|
|
def test_size_score_bands():
|
|
assert get_size_score(None) == 5
|
|
assert get_size_score(64) == 5
|
|
assert get_size_score(256) == 7
|
|
assert get_size_score(1024) == 10
|
|
|
|
|
|
def test_score_device_sums_type_and_size(monkeypatch):
|
|
import drives
|
|
|
|
monkeypatch.setattr(drives, "get_drive_health", lambda _: 10)
|
|
assert score_device("/dev/nvme0n1", 1024) == 15 + 10 + 10
|
|
assert score_device("/dev/sda", 64) == 5 + 10 + 5
|
|
|
|
|
|
def test_parse_lsblk_drops_loop_and_rom(monkeypatch):
|
|
import drives
|
|
|
|
monkeypatch.setattr(drives, "get_drive_health", lambda _: 10)
|
|
output = "loop0 2.5G loop\nsr0 1024M rom\nsda 500G disk\nnvme0n1 1T disk\n"
|
|
devices = parse_lsblk_output(output)
|
|
names = [d["name"] for d in devices]
|
|
assert names == ["/dev/nvme0n1", "/dev/sda"]
|
|
|
|
|
|
def test_parse_lsblk_handles_empty_output():
|
|
assert parse_lsblk_output("") == []
|