111 lines
4.3 KiB
Python
111 lines
4.3 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
|
|
from govoplan_admin.backend.manifest import manifest
|
|
|
|
|
|
class InterfaceDocumentationContractTests(unittest.TestCase):
|
|
def test_all_static_topics_have_complete_german_content(self) -> None:
|
|
for topic in manifest.documentation:
|
|
german = (topic.translations or {}).get("de", {})
|
|
self.assertEqual(
|
|
{"title", "summary", "body"},
|
|
set(german),
|
|
topic.id,
|
|
)
|
|
self.assertTrue(
|
|
all(str(value).strip() for value in german.values()), topic.id
|
|
)
|
|
|
|
def test_admin_topics_publish_stable_help_contexts(self) -> None:
|
|
topics = {topic.id: topic for topic in manifest.documentation}
|
|
expected = {
|
|
"admin.workspace": {"admin.workspace", "admin.overview"},
|
|
"admin.governance-and-module-lifecycle": {
|
|
"admin.system-settings",
|
|
"admin.configuration-changes",
|
|
"admin.configuration-packages",
|
|
"admin.governance-templates",
|
|
},
|
|
"admin.language-reference-and-packages": {
|
|
"admin.system-language-packages",
|
|
"admin.system-language-packages.compatibility",
|
|
},
|
|
"admin.module-lifecycle-workflow": {
|
|
"admin.module-lifecycle",
|
|
"admin.module-lifecycle.queue-blocker",
|
|
"admin.module-lifecycle.plan",
|
|
"admin.module-lifecycle.evidence",
|
|
},
|
|
"admin.tenant-module-entitlements": {
|
|
"admin.system-tenant-modules",
|
|
"admin.tenant-modules",
|
|
},
|
|
}
|
|
for topic_id, contexts in expected.items():
|
|
self.assertIn(topic_id, topics)
|
|
metadata = topics[topic_id].metadata or {}
|
|
self.assertTrue(
|
|
contexts.issubset(set(metadata.get("help_contexts", ()))),
|
|
topic_id,
|
|
)
|
|
|
|
def test_admin_contributed_surfaces_remain_declared(self) -> None:
|
|
surface_ids = {surface.id for surface in manifest.frontend.view_surfaces}
|
|
self.assertEqual(
|
|
surface_ids,
|
|
{
|
|
"admin.section.overview",
|
|
"admin.section.system-settings",
|
|
"admin.section.system-language-packages",
|
|
"admin.section.system-configuration-changes",
|
|
"admin.section.system-configuration-packages",
|
|
"admin.section.system-role-templates",
|
|
"admin.section.system-groups",
|
|
"admin.section.system-modules",
|
|
"admin.section.system-tenant-modules",
|
|
"admin.section.tenant-data-subject-requests",
|
|
"admin.section.tenant-modules",
|
|
},
|
|
)
|
|
|
|
def test_configuration_package_help_explains_safety_boundaries(self) -> None:
|
|
topic = next(
|
|
item
|
|
for item in manifest.documentation
|
|
if item.id == "admin.governance-and-module-lifecycle"
|
|
)
|
|
|
|
self.assertIn("previous preflight stale", topic.body)
|
|
self.assertIn("partial apply requires recovery", topic.body)
|
|
self.assertIn("provenance", topic.body)
|
|
german = (topic.translations or {}).get("de", {})
|
|
self.assertIn("vorherige Vorprüfung ungültig", german.get("body", ""))
|
|
self.assertIn("Teilanwendung Wiederherstellung", german.get("body", ""))
|
|
|
|
metadata = topic.metadata or {}
|
|
self.assertIn(
|
|
"Generic rollback is snapshot recovery; providers may expose narrower compensation separately.",
|
|
metadata.get("limitations", ()),
|
|
)
|
|
self.assertIn(
|
|
"Changing package inputs invalidates the previous preflight and requires another review.",
|
|
metadata.get("operational_consequences", ()),
|
|
)
|
|
|
|
def test_module_administrator_has_only_tenant_module_permissions(self) -> None:
|
|
permissions = {item.scope for item in manifest.permissions}
|
|
template = next(
|
|
item for item in manifest.role_templates if item.slug == "module_admin"
|
|
)
|
|
|
|
self.assertEqual({"admin:module:read", "admin:module:write"}, permissions)
|
|
self.assertEqual(
|
|
tuple(sorted(permissions)), tuple(sorted(template.permissions))
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|