2021-08-17 18:48:25 +02:00
|
|
|
from pathlib import Path
|
|
|
|
|
2021-09-07 23:10:21 +02:00
|
|
|
from tools.packages import list_packages, load_packages
|
2021-08-17 18:48:25 +02:00
|
|
|
|
2021-09-07 23:10:21 +02:00
|
|
|
PACKAGE_INI = """
|
2021-08-17 18:48:25 +02:00
|
|
|
[common]
|
2021-11-04 08:55:50 +01:00
|
|
|
postgresql = buster, focal
|
2021-08-17 18:48:25 +02:00
|
|
|
# Some comment
|
2022-09-09 19:52:46 +02:00
|
|
|
curl = buster, bullseye
|
2021-08-17 18:48:25 +02:00
|
|
|
|
|
|
|
[legacy]
|
2022-09-09 19:52:46 +02:00
|
|
|
some-package = bullseye, focal
|
2021-08-17 18:48:25 +02:00
|
|
|
|
|
|
|
[=development]
|
2022-09-09 19:52:46 +02:00
|
|
|
ffmpeg = buster, bullseye, focal
|
2021-08-17 18:48:25 +02:00
|
|
|
"""
|
|
|
|
|
2021-11-04 08:55:50 +01:00
|
|
|
result_buster = {"curl", "postgresql"}
|
2022-09-09 19:52:46 +02:00
|
|
|
result_bullseye = {"some-package", "curl", "ffmpeg"}
|
2022-07-06 15:21:18 +02:00
|
|
|
result_focal = {"postgresql", "some-package", "ffmpeg"}
|
2022-01-10 07:23:37 +01:00
|
|
|
result_exclude = {"postgresql", "ffmpeg"}
|
2021-08-17 18:48:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_load_packages():
|
2021-11-04 08:55:50 +01:00
|
|
|
assert load_packages(PACKAGE_INI, "buster", False) == result_buster
|
2022-09-09 19:52:46 +02:00
|
|
|
assert load_packages(PACKAGE_INI, "bullseye", True) == result_bullseye
|
2021-11-04 08:55:50 +01:00
|
|
|
assert load_packages(PACKAGE_INI, "focal", True) == result_focal
|
2022-01-10 07:23:37 +01:00
|
|
|
assert load_packages(PACKAGE_INI, "focal", True, ["legacy"]) == result_exclude
|
2021-08-17 18:48:25 +02:00
|
|
|
|
|
|
|
|
2022-01-22 17:03:39 +01:00
|
|
|
def test_list_packages(tmp_path: Path) -> None:
|
2021-08-17 18:48:25 +02:00
|
|
|
package_file = tmp_path / "packages.ini"
|
2021-09-07 23:10:21 +02:00
|
|
|
package_file.write_text(PACKAGE_INI)
|
2021-08-17 18:48:25 +02:00
|
|
|
|
2021-11-04 08:55:50 +01:00
|
|
|
assert list_packages([tmp_path, package_file], "buster", False) == result_buster
|
2022-09-09 19:52:46 +02:00
|
|
|
assert list_packages([tmp_path, package_file], "bullseye", True) == result_bullseye
|
2021-11-04 08:55:50 +01:00
|
|
|
assert list_packages([tmp_path, package_file], "focal", True) == result_focal
|