libretime/tools/packages_test.py

36 lines
1016 B
Python
Raw Normal View History

from pathlib import Path
2021-09-07 23:10:21 +02:00
from tools.packages import list_packages, load_packages
2021-09-07 23:10:21 +02:00
PACKAGE_INI = """
[common]
postgresql = buster, focal
# Some comment
curl = buster, bionic
[legacy]
apache2 = bionic, focal
[=development]
ffmpeg = buster, bionic, focal
"""
result_buster = {"curl", "postgresql"}
result_bionic = {"apache2", "curl", "ffmpeg"}
result_focal = {"postgresql", "apache2", "ffmpeg"}
def test_load_packages():
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
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)
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