Files
govoplan/tests/test_release_catalog_entry_synthesis.py
Albrecht Degering ba88c574b9
Some checks failed
Dependency Audit / dependency-audit (push) Has been cancelled
Security Audit / security-audit (push) Has been cancelled
chore: move repositories to GovOPlaN organization
2026-07-27 15:46:51 +02:00

85 lines
3.2 KiB
Python

from __future__ import annotations
import sys
import unittest
from pathlib import Path
META_ROOT = Path(__file__).resolve().parents[1]
RELEASE_ROOT = META_ROOT / "tools" / "release"
if str(RELEASE_ROOT) not in sys.path:
sys.path.insert(0, str(RELEASE_ROOT))
from govoplan_release.catalog_entry_synthesis import validate_initial_entry_closure # noqa: E402
from govoplan_release.selective_catalog import apply_repo_updates # noqa: E402
class ReleaseCatalogEntrySynthesisTests(unittest.TestCase):
def test_selective_update_synthesizes_initial_entries_from_package_manifests(self) -> None:
payload: dict[str, object] = {
"core_release": {},
"release": {},
"modules": [
{
"module_id": "access",
"version": "0.1.11",
"python_package": "govoplan-access",
"python_ref": "govoplan-access @ git+ssh://git@git.add-ideas.de/GovOPlaN/govoplan-access.git@v0.1.11",
}
],
}
changes = apply_repo_updates(
payload,
repo_versions={
"govoplan-addresses": "0.1.9",
"govoplan-poll": "0.1.11",
"govoplan-scheduling": "0.1.11",
},
repo_contracts={},
repository_base="git+ssh://git@git.add-ideas.de/GovOPlaN",
workspace=META_ROOT.parent,
)
modules = {
item["module_id"]: item
for item in payload["modules"] # type: ignore[index]
}
self.assertEqual({"access", "addresses", "poll", "scheduling"}, set(modules))
self.assertEqual("@govoplan/addresses-webui", modules["addresses"]["webui_package"])
self.assertIn(
{"name": "addresses.people_search", "version": "0.1.0"},
modules["addresses"]["provides_interfaces"],
)
self.assertEqual("govoplan-poll", modules["poll"]["python_package"])
self.assertEqual(["poll"], modules["scheduling"]["dependencies"])
self.assertEqual("@govoplan/scheduling-webui", modules["scheduling"]["webui_package"])
self.assertEqual("requires_review", modules["scheduling"]["migration_safety"])
self.assertTrue(
any(
item["name"] == "poll.governed_participation" and item["optional"] is False
for item in modules["scheduling"]["requires_interfaces"]
)
)
self.assertEqual(
{"govoplan-addresses", "govoplan-poll", "govoplan-scheduling"},
{change.repo for change in changes},
)
self.assertEqual({"catalog_entry"}, {change.field for change in changes})
def test_initial_required_dependency_must_be_represented(self) -> None:
with self.assertRaisesRegex(ValueError, "requires catalog module 'poll'"):
validate_initial_entry_closure(
catalog_modules=[
{
"module_id": "scheduling",
"dependencies": ["poll"],
}
],
initial_module_ids={"scheduling"},
)
if __name__ == "__main__":
unittest.main()