68 lines
2.7 KiB
Python
68 lines
2.7 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
|
|
from govoplan_core.core.modules import (
|
|
documentation_structured_translation_issues,
|
|
localizable_documentation_metadata_keys,
|
|
)
|
|
from govoplan_organizations.backend.manifest import manifest
|
|
|
|
|
|
class OrganizationsInterfaceDocumentationContractTests(unittest.TestCase):
|
|
def test_route_and_admin_surface_remain_declared(self) -> None:
|
|
frontend = manifest.frontend
|
|
self.assertIsNotNone(frontend)
|
|
self.assertEqual(
|
|
{"/organizations"},
|
|
{route.path for route in frontend.routes}, # type: ignore[union-attr]
|
|
)
|
|
self.assertEqual(
|
|
{
|
|
"organizations.admin.tenant",
|
|
"organizations.admin.template-upgrades",
|
|
},
|
|
{surface.id for surface in frontend.view_surfaces}, # type: ignore[union-attr]
|
|
)
|
|
self.assertTrue(
|
|
all(item.icon == "building-2" for item in manifest.nav_items)
|
|
)
|
|
|
|
def test_topics_publish_stable_help_and_consequence_metadata(self) -> None:
|
|
topics = {topic.id: topic for topic in manifest.documentation}
|
|
self.assertIn("organizations.model", topics)
|
|
self.assertIn("organizations.reference.fields-and-consequences", topics)
|
|
self.assertIn(
|
|
"organizations.admin.tenant",
|
|
topics["organizations.model"].metadata["help_contexts"],
|
|
)
|
|
reference = topics["organizations.reference.fields-and-consequences"]
|
|
self.assertIn(
|
|
"organizations.field.change-request",
|
|
reference.metadata["help_contexts"],
|
|
)
|
|
self.assertIn("hierarchy_change", reference.metadata["consequence_classes"])
|
|
|
|
def test_german_reference_documentation_is_complete(self) -> None:
|
|
topics = manifest.documentation
|
|
self.assertEqual(4, len(topics))
|
|
for topic in topics:
|
|
translation = topic.translations.get("de", {})
|
|
self.assertTrue(translation.get("title"), topic.id)
|
|
self.assertTrue(translation.get("summary"), topic.id)
|
|
self.assertTrue(translation.get("body"), topic.id)
|
|
if localizable_documentation_metadata_keys(topic):
|
|
self.assertEqual("1", topic.structured_translation_version, topic.id)
|
|
self.assertIn("de", topic.structured_translations, topic.id)
|
|
self.assertEqual((), documentation_structured_translation_issues(topic))
|
|
|
|
kinds = {topic.metadata.get("kind") for topic in topics}
|
|
self.assertIn("workflow", kinds)
|
|
self.assertIn("reference", kinds)
|
|
workflow = next(topic for topic in topics if topic.metadata.get("kind") == "workflow")
|
|
self.assertTrue(workflow.conditions)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|