Release govoplan-views v0.1.22: unify interface contracts and documentation
This commit is contained in:
@@ -207,6 +207,12 @@ class ViewsServiceTests(unittest.TestCase):
|
||||
catalogue=self.catalogue,
|
||||
actor_id="account-admin",
|
||||
presentation={
|
||||
"navigation": {
|
||||
"contract_version": "1",
|
||||
"order": ["separator:work", "files.nav.files"],
|
||||
"hidden": ["mail.nav.mail"],
|
||||
"separators": [{"id": "separator:work", "label": "My work"}],
|
||||
},
|
||||
"navigation_mode": "grouped",
|
||||
"product_area_order": ["work", "records-documents"],
|
||||
"product_area_labels": {"work": "My work"},
|
||||
@@ -254,6 +260,40 @@ class ViewsServiceTests(unittest.TestCase):
|
||||
catalogue=self.catalogue,
|
||||
)
|
||||
self.assertEqual("My work", state.effective.presentation["product_area_labels"]["work"])
|
||||
self.assertEqual(revision.presentation["navigation"], state.effective.presentation["navigation"])
|
||||
changed = create_revision(
|
||||
self.session,
|
||||
definition,
|
||||
visible_surface_ids=lockout_safe_surface_ids(),
|
||||
catalogue=self.catalogue,
|
||||
actor_id="account-admin",
|
||||
presentation={**revision.presentation, "navigation": {"separators": []}},
|
||||
)
|
||||
self.assertNotEqual(revision.content_hash, changed.content_hash)
|
||||
self.assertEqual([], changed.presentation["navigation"]["separators"])
|
||||
self.assertEqual("My work", revision.presentation["navigation"]["separators"][0]["label"])
|
||||
|
||||
def test_view_navigation_inheritance_flatness_and_bounds(self) -> None:
|
||||
self.assertNotIn("navigation", normalize_view_presentation({}))
|
||||
self.assertIsNone(normalize_view_presentation({"navigation": None})["navigation"])
|
||||
inherited = normalize_view_presentation({"navigation": {"order": [" files.nav.files ", "files.nav.files"]}})["navigation"]
|
||||
self.assertEqual(["files.nav.files"], inherited["order"])
|
||||
self.assertNotIn("separators", inherited)
|
||||
flat = normalize_view_presentation({"navigation": {"separators": []}})["navigation"]
|
||||
self.assertEqual([], flat["separators"])
|
||||
for navigation in (
|
||||
{"locked": ["files.nav.files"]},
|
||||
{"grant": ["files.read"]},
|
||||
{"contract_version": "2"},
|
||||
{"order": ["files.nav.files"] * 257},
|
||||
{"hidden": ["files.nav.files"] * 257},
|
||||
{"separators": [{"id": "separator:work", "label": "a" * 121}]},
|
||||
{"separators": [{"id": "files.nav.files", "label": "Not a separator"}]},
|
||||
{"separators": [{"id": "separator:work", "label": "Unsafe\nlabel"}]},
|
||||
{"separators": [{"id": "separator:work", "private": "payload"}]},
|
||||
):
|
||||
with self.subTest(navigation=navigation), self.assertRaises(ViewsValidationError):
|
||||
normalize_view_presentation({"navigation": navigation})
|
||||
|
||||
def test_view_presentation_rejects_unknown_or_unavailable_fields(self) -> None:
|
||||
with self.assertRaises(ViewsValidationError):
|
||||
|
||||
Reference in New Issue
Block a user