pmb: Split devices by category during codename selection

This also reworks list_codenames() somewhat. The option to show archived
devices is removed as it never actually was used. It should be easy to
restore if someone is interested.

Closes https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2558

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2549
This commit is contained in:
Newbyte 2025-02-11 18:51:40 +01:00 committed by Oliver Smith
parent a9c3628297
commit cd672222c4
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
3 changed files with 173 additions and 16 deletions

View file

@ -0,0 +1,26 @@
# Copyright 2025 Stefan Hansson
# SPDX-License-Identifier: GPL-3.0-or-later
from .devices import DeviceCategory, get_device_category_by_apkbuild_path
from pathlib import Path
import pytest
def test_get_device_category_by_apkbuild_path() -> None:
valid_path_1 = Path("device") / "community" / "device-samsung-m0" / "APKBUILD"
valid_path_2 = Path("pmos_work") / "device" / "main" / "device-pine64-pinephone" / "APKBUILD"
# Missing category segment of path.
invalid_path_1 = Path("APKBUILD")
# Nonexistent category ("pendeltåg").
invalid_path_2 = Path("device") / "pendeltåg" / "device-samsung-m0" / "APKBUILD"
assert get_device_category_by_apkbuild_path(valid_path_1) == DeviceCategory.COMMUNITY
assert get_device_category_by_apkbuild_path(valid_path_2) == DeviceCategory.MAIN
with pytest.raises(RuntimeError):
get_device_category_by_apkbuild_path(invalid_path_1)
with pytest.raises(RuntimeError):
get_device_category_by_apkbuild_path(invalid_path_2)