Files
singbox_glue/tests/test_packaging.py
T

54 lines
2.2 KiB
Python

from __future__ import annotations
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
class PackagingTests(unittest.TestCase):
def test_makefile_supports_src_layout(self) -> None:
makefile = (ROOT / "Makefile").read_text(encoding="utf-8")
self.assertIn("PYTHONPATH=src:.", makefile)
def test_release_metadata_is_mpl_2_and_version_0_2(self) -> None:
pyproject = (ROOT / "pyproject.toml").read_text(encoding="utf-8")
self.assertIn('version = "0.2.0"', pyproject)
self.assertIn('license = "MPL-2.0"', pyproject)
license_text = (ROOT / "LICENSE").read_text(encoding="utf-8")
self.assertIn("Mozilla Public License Version 2.0", license_text)
debian_copyright = (ROOT / "debian/copyright").read_text(encoding="utf-8")
self.assertIn("License: MPL-2.0", debian_copyright)
def test_debian_dependency_is_exactly_1_14_0(self) -> None:
control = (ROOT / "debian/control").read_text(encoding="utf-8")
self.assertIn("sing-box (= 1.14.0)", control)
def test_in_place_upgrade_is_rejected(self) -> None:
preinst = (ROOT / "debian/preinst").read_text(encoding="utf-8")
self.assertIn('[ "$1" = upgrade ]', preinst)
self.assertIn("exit 1", preinst)
def test_postinst_checks_for_legacy_state(self) -> None:
postinst = (ROOT / "debian/postinst").read_text(encoding="utf-8")
self.assertIn("vpn_egressctl.installcheck", postinst)
def test_sing_box_drop_in_requires_guard(self) -> None:
drop_in = ROOT / "packaging/systemd/sing-box.service.d/10-vpn-egress-guard.conf"
text = drop_in.read_text(encoding="utf-8")
self.assertIn("Requires=vpn-egress-guard.service", text)
self.assertIn("After=vpn-egress-guard.service", text)
def test_debian_package_installs_sing_box_drop_in(self) -> None:
install = (ROOT / "debian/install").read_text(encoding="utf-8")
self.assertIn(
"packaging/systemd/sing-box.service.d/10-vpn-egress-guard.conf "
"usr/lib/systemd/system/sing-box.service.d",
install,
)
if __name__ == "__main__":
unittest.main()