libretime/tools/packages_test.py

33 lines
757 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
# Some comment
curl = buster, bionic
[legacy]
apache2 = bionic
[=development]
ffmpeg = buster, bionic
"""
result1 = {"curl", "postgresql"}
result2 = {"apache2", "curl", "ffmpeg"}
def test_load_packages():
2021-09-07 23:10:21 +02:00
assert load_packages(PACKAGE_INI, "buster", False) == result1
assert load_packages(PACKAGE_INI, "bionic", True) == result2
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) == result1
assert list_packages([tmp_path, package_file], "bionic", True) == result2