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
|
|
|
|
curl = buster, bionic
|
|
|
|
|
|
|
|
[legacy]
|
2021-11-04 08:55:50 +01:00
|
|
|
apache2 = bionic, focal
|
2021-08-17 18:48:25 +02:00
|
|
|
|
|
|
|
[=development]
|
2021-11-04 08:55:50 +01:00
|
|
|
ffmpeg = buster, bionic, focal
|
2021-08-17 18:48:25 +02:00
|
|
|
"""
|
|
|
|
|
2021-11-04 08:55:50 +01:00
|
|
|
result_buster = {"curl", "postgresql"}
|
|
|
|
result_bionic = {"apache2", "curl", "ffmpeg"}
|
|
|
|
result_focal = {"postgresql", "apache2", "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
|
|
|
|
assert load_packages(PACKAGE_INI, "bionic", True) == result_bionic
|
|
|
|
assert load_packages(PACKAGE_INI, "focal", True) == result_focal
|
2021-08-17 18:48:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_list_packages(tmp_path: Path):
|
|
|
|
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
|
|
|
|
assert list_packages([tmp_path, package_file], "bionic", True) == result_bionic
|
|
|
|
assert list_packages([tmp_path, package_file], "focal", True) == result_focal
|