diff --git a/cli/build/docs/readme/architecture.py b/cli/build/docs/readme/architecture.py index edc87dc579..a46f56fd84 100644 --- a/cli/build/docs/readme/architecture.py +++ b/cli/build/docs/readme/architecture.py @@ -144,16 +144,20 @@ def _volumes_legend() -> list[str]: return [ "| Condition | Effect |", "| --- | --- |", - "| swarm, `storage.backend: nfs`, no `nfs: false`, role not pinned " - "| shared over NFS |", + ( + "| swarm, `storage.backend: nfs`, no `nfs: false`, role not pinned " + "| shared over NFS |" + ), "| any one of those missing | node-local |", "", - "All four conditions must hold, so pinning a role takes every one of " - "its volumes node-local. Only the role's primary entry counts as " - "pinned here: a `placement` on any other service pins that service " - "alone and leaves the backing of every volume unchanged. The chain is " - "drawn rather than its result, because that coupling is what makes a " - "placement change move data without saying so.", + ( + "All four conditions must hold, so pinning a role takes every one of " + "its volumes node-local. Only the role's primary entry counts as " + "pinned here: a `placement` on any other service pins that service " + "alone and leaves the backing of every volume unchanged. The chain is " + "drawn rather than its result, because that coupling is what makes a " + "placement change move data without saying so." + ), ] @@ -168,8 +172,10 @@ def _dependencies_legend() -> list[str]: f"| {to_emoji('compose')} | deploys under compose |", f"| {to_emoji('swarm')} | deploys under swarm |", f"| {to_emoji('disabled')} | service explicitly turned off |", - f"| {to_emoji('role_dependency')} | Ansible role dependency from " - "`meta/main.yml` |", + ( + f"| {to_emoji('role_dependency')} | Ansible role dependency from " + "`meta/main.yml` |" + ), "", "Every dependency and dependent is listed; the graph is not truncated.", ] @@ -185,9 +191,7 @@ def derive_architecture_page(role_dir, role_name: str, app_name: str = "") -> st after it so both documents name the application the same way. """ role_dir = Path(role_dir) - role_placement = ( - get_role_placement(role_dir, role_name=role_name) or "" - ).strip() + role_placement = (get_role_placement(role_dir, role_name=role_name) or "").strip() sections = [ f"# {app_name or role_name} Architecture", "", diff --git a/tests/unit/python/cli/build/docs/readme/test_architecture.py b/tests/unit/python/cli/build/docs/readme/test_architecture.py new file mode 100644 index 0000000000..f6432f6c66 --- /dev/null +++ b/tests/unit/python/cli/build/docs/readme/test_architecture.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +import unittest + +from cli.build.docs.readme.architecture import _volumes_legend + + +class TestVolumesLegend(unittest.TestCase): + def test_each_table_row_is_one_item_with_the_columns_of_the_header(self): + rows = [line for line in _volumes_legend() if line.startswith("|")] + self.assertEqual([3, 3, 3, 3], [row.count("|") for row in rows]) + self.assertIn("role not pinned | shared over NFS |", rows[2]) + + def test_the_explanation_below_the_table_is_one_paragraph(self): + prose = [line for line in _volumes_legend() if line and line[0] != "|"] + self.assertEqual(1, len(prose)) + self.assertTrue(prose[0].startswith("All four conditions must hold")) + self.assertTrue(prose[0].endswith("move data without saying so.")) + + +if __name__ == "__main__": + unittest.main()