feat(release): synthesize initial catalog entries
This commit is contained in:
84
tests/test_release_catalog_entry_synthesis.py
Normal file
84
tests/test_release_catalog_entry_synthesis.py
Normal file
@@ -0,0 +1,84 @@
|
||||
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/add-ideas/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/add-ideas",
|
||||
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()
|
||||
Reference in New Issue
Block a user