feat(docs): localize structured metadata and gate coverage
This commit is contained in:
@@ -11,6 +11,8 @@ from govoplan_docs.public_export import (
|
||||
ManifestSource,
|
||||
build_public_catalog,
|
||||
catalog_matches_sources,
|
||||
coverage_baseline,
|
||||
coverage_regression_issues,
|
||||
documentation_coverage_markdown,
|
||||
write_public_catalog,
|
||||
)
|
||||
@@ -25,6 +27,13 @@ class PublicDocumentationExportTests(unittest.TestCase):
|
||||
self.assertEqual(9, module["coverage"]["topic_count"])
|
||||
self.assertEqual(0, module["coverage"]["missing_german_topic_count"])
|
||||
self.assertEqual([], module["coverage"]["missing_german_topic_ids"])
|
||||
self.assertEqual(2, module["coverage"]["structured_localizable_topic_count"])
|
||||
self.assertEqual(
|
||||
2, module["coverage"]["german_structured_complete_topic_count"]
|
||||
)
|
||||
self.assertEqual(
|
||||
[], module["coverage"]["missing_german_structured_topic_ids"]
|
||||
)
|
||||
self.assertEqual([], module["coverage"]["missing"])
|
||||
|
||||
def test_catalog_projects_localized_manifest_topics_and_gaps(self) -> None:
|
||||
@@ -39,7 +48,11 @@ class PublicDocumentationExportTests(unittest.TestCase):
|
||||
summary="Perform the example workflow.",
|
||||
body="Open and finish it.",
|
||||
documentation_types=("user", "admin"),
|
||||
metadata={"kind": "workflow"},
|
||||
metadata={
|
||||
"kind": "workflow",
|
||||
"steps": ["Review", "Execute"],
|
||||
"verification": "Confirm completion.",
|
||||
},
|
||||
translations={
|
||||
"de": {
|
||||
"title": "Beispiel verwenden",
|
||||
@@ -47,6 +60,13 @@ class PublicDocumentationExportTests(unittest.TestCase):
|
||||
"body": "Öffnen und abschließen.",
|
||||
}
|
||||
},
|
||||
structured_translation_version="1",
|
||||
structured_translations={
|
||||
"de": {
|
||||
"steps": ["Prüfen", "Ausführen"],
|
||||
"verification": "Den Abschluss bestätigen.",
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -59,7 +79,12 @@ class PublicDocumentationExportTests(unittest.TestCase):
|
||||
self.assertEqual("Beispiel verwenden", topic["localizations"]["de"]["title"])
|
||||
self.assertTrue(topic["localizations"]["de"]["complete"])
|
||||
self.assertEqual("workflow", topic["kind"])
|
||||
self.assertEqual({}, topic["content"])
|
||||
self.assertEqual(["Review", "Execute"], topic["content"]["steps"])
|
||||
self.assertEqual(
|
||||
["Prüfen", "Ausführen"],
|
||||
topic["content_localizations"]["de"]["content"]["steps"],
|
||||
)
|
||||
self.assertTrue(topic["content_localizations"]["de"]["complete"])
|
||||
self.assertIn(
|
||||
"field/consequence reference",
|
||||
catalog["modules"][0]["coverage"]["missing"],
|
||||
@@ -159,6 +184,57 @@ class PublicDocumentationExportTests(unittest.TestCase):
|
||||
|
||||
self.assertEqual("operator-workflow", topic["kind"])
|
||||
|
||||
def test_coverage_baseline_rejects_text_and_structured_regressions(self) -> None:
|
||||
healthy = build_public_catalog(
|
||||
(
|
||||
ManifestSource(
|
||||
ModuleManifest(
|
||||
id="example",
|
||||
name="Example",
|
||||
version="1.0.0",
|
||||
documentation=(
|
||||
DocumentationTopic(
|
||||
id="example.reference",
|
||||
title="Reference",
|
||||
summary="Reference summary.",
|
||||
body="Reference body.",
|
||||
translations={
|
||||
"de": {
|
||||
"title": "Referenz",
|
||||
"summary": "Referenzzusammenfassung.",
|
||||
"body": "Referenzinhalt.",
|
||||
}
|
||||
},
|
||||
metadata={
|
||||
"kind": "reference",
|
||||
"limitations": ["Source limitation."],
|
||||
},
|
||||
structured_translation_version="1",
|
||||
structured_translations={
|
||||
"de": {
|
||||
"limitations": [
|
||||
"Einschränkung der Quelle."
|
||||
]
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
)
|
||||
baseline = coverage_baseline(healthy)
|
||||
self.assertEqual((), coverage_regression_issues(healthy, baseline))
|
||||
|
||||
regressed = json.loads(json.dumps(healthy))
|
||||
regressed["summary"]["german_complete_topic_count"] = 0
|
||||
regressed["summary"]["german_structured_complete_topic_count"] = 0
|
||||
issues = coverage_regression_issues(regressed, baseline)
|
||||
self.assertTrue(any("german_complete_topic_count" in issue for issue in issues))
|
||||
self.assertTrue(
|
||||
any("german_structured_complete_topic_count" in issue for issue in issues)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user