46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
import pathlib
|
|
import tomllib
|
|
import unittest
|
|
|
|
from govoplan_core.core.policy import (
|
|
CAPABILITY_POLICY_PRIVACY_RETENTION,
|
|
CAPABILITY_POLICY_SCHEDULING_PARTICIPANT_PRIVACY,
|
|
)
|
|
from govoplan_policy.backend.manifest import manifest
|
|
|
|
|
|
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
|
|
|
|
|
class PolicyModuleContractTests(unittest.TestCase):
|
|
def test_policy_package_does_not_hard_require_access(self) -> None:
|
|
project = tomllib.loads((ROOT / "pyproject.toml").read_text(encoding="utf-8"))["project"]
|
|
dependencies = tuple(project["dependencies"])
|
|
|
|
self.assertTrue(any(item.startswith("govoplan-core>=") for item in dependencies))
|
|
self.assertFalse(any(item.startswith("govoplan-access") for item in dependencies))
|
|
|
|
def test_policy_source_does_not_import_access_implementation(self) -> None:
|
|
offenders: list[str] = []
|
|
for path in (ROOT / "src" / "govoplan_policy").rglob("*.py"):
|
|
source = path.read_text(encoding="utf-8")
|
|
if "govoplan_access" in source:
|
|
offenders.append(str(path.relative_to(ROOT)))
|
|
|
|
self.assertEqual([], offenders)
|
|
|
|
def test_policy_manifest_exposes_policy_capabilities(self) -> None:
|
|
self.assertEqual(
|
|
{
|
|
CAPABILITY_POLICY_PRIVACY_RETENTION,
|
|
CAPABILITY_POLICY_SCHEDULING_PARTICIPANT_PRIVACY,
|
|
},
|
|
set(manifest.capability_factories),
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|