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]
|
|
|
|
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
|
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
|
|
|
|
|
|
|
assert list_packages([tmp_path, package_file], "buster", False) == result1
|
|
|
|
assert list_packages([tmp_path, package_file], "bionic", True) == result2
|