mirror of
https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git
synced 2025-07-12 19:09:56 +03:00
Consequence of tests being moved back and forth over time.
Fixes cd672222c4
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2616
26 lines
1 KiB
Python
26 lines
1 KiB
Python
# Copyright 2025 Stefan Hansson
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
from pmb.helpers.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)
|