Migrate Templates interface patterns

This commit is contained in:
2026-08-03 13:34:37 +02:00
parent 3551c48e14
commit 72fafa23c7
7 changed files with 399 additions and 28 deletions
@@ -0,0 +1,37 @@
from __future__ import annotations
import unittest
from govoplan_templates.backend.manifest import manifest
class TemplatesInterfaceDocumentationContractTests(unittest.TestCase):
def test_route_and_surfaces_remain_declared(self) -> None:
frontend = manifest.frontend
self.assertIsNotNone(frontend)
self.assertEqual({"/templates"}, {item.path for item in frontend.routes}) # type: ignore[union-attr]
self.assertEqual(
{
"templates.page",
"templates.library",
"templates.editor",
"templates.preview",
},
{item.id for item in frontend.view_surfaces}, # type: ignore[union-attr]
)
def test_help_and_consequence_metadata_remain_published(self) -> None:
topics = {topic.id: topic for topic in manifest.documentation}
library = topics["templates.library"]
output = topics["templates.printable-output"]
reference = topics["templates.reference.fields-and-consequences"]
self.assertIn("templates.state.read-only", library.metadata["help_contexts"])
self.assertIn("templates.action.render-final", output.metadata["help_contexts"])
self.assertIn("templates.field.usages", reference.metadata["help_contexts"])
self.assertIn("publish_revision", reference.metadata["consequence_classes"])
self.assertIn("delete_template", reference.metadata["consequence_classes"])
if __name__ == "__main__":
unittest.main()