mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-09 12:17:13 +00:00
Two store-i18n-only code paths predate updater's custom roles (web-app-cst-*,d92375922d), which the mergec9e7f950d9brought in: - utils/i18n/libretranslate.py deploys the translation tools lane with cli.administration.deploy.dedicated but without --skip-pull. The lane bind-mounts the checkout and its generated inventory declares no custom role, so `make i18n-translate` would have run pull_custom_roles and removed every pulled web-app-cst-* from the host's roles/. It now passes --skip-pull, as every other generated deploy does. - utils/i18n/extract.py role_messages globbed roles/*/meta/main.yml, including the gitignored custom roles, so a checkout with a pulled custom role failed test_core_catalogs_hold_exactly_the_current_sources and its remedy would have written the custom role's description into every tracked core catalog, against updater's rule that core never tracks custom roles. It now skips is_custom(role), like the README generators. test_a_pulled_custom_role_stays_out_of_the_core_catalogs pins the second point; without the skip it fails with the custom role in the list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99 lines
3.1 KiB
Python
99 lines
3.1 KiB
Python
import tempfile
|
|
import textwrap
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from utils.i18n.extract import core_messages, role_messages
|
|
from utils.roles.mapping import ROLE_FILE_META_MAIN
|
|
|
|
|
|
def _write(root: Path, relative: str, content: str) -> None:
|
|
path = root / relative
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
path.write_text(textwrap.dedent(content), encoding="utf-8")
|
|
|
|
|
|
class TestCoreMessages(unittest.TestCase):
|
|
def test_every_source_yields_messages_under_its_context(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
root = Path(tmp)
|
|
_write(
|
|
root,
|
|
f"roles/web-app-wiki/{ROLE_FILE_META_MAIN}",
|
|
"""\
|
|
galaxy_info:
|
|
description: " A wiki "
|
|
""",
|
|
)
|
|
_write(
|
|
root, f"roles/web-app-plain/{ROLE_FILE_META_MAIN}", "galaxy_info: {}\n"
|
|
)
|
|
_write(
|
|
root,
|
|
"meta/categories.yml",
|
|
"""\
|
|
roles:
|
|
web:
|
|
title: Web
|
|
glyph: 𓏴
|
|
app:
|
|
title: Applications
|
|
description: Apps for users
|
|
invokable: true
|
|
""",
|
|
)
|
|
_write(
|
|
root,
|
|
"roles/web-app-dashboard/vars/menu_categories.yml",
|
|
"""\
|
|
portfolio_menu_categories:
|
|
Community:
|
|
description: Tools to manage the community
|
|
tags: [forum]
|
|
""",
|
|
)
|
|
_write(
|
|
root,
|
|
"roles/web-app-keycloak/files/logout_i18n.yml",
|
|
"""\
|
|
counter: "{done} of {total} services signed out"
|
|
""",
|
|
)
|
|
|
|
messages = core_messages(root)
|
|
|
|
self.assertEqual(
|
|
messages,
|
|
[
|
|
("role:web-app-wiki:description", "A wiki"),
|
|
("category:web:title", "Web"),
|
|
("category:web.app:title", "Applications"),
|
|
("category:web.app:description", "Apps for users"),
|
|
("menu:Community:title", "Community"),
|
|
("menu:Community:description", "Tools to manage the community"),
|
|
("logout:counter", "{done} of {total} services signed out"),
|
|
],
|
|
)
|
|
|
|
def test_a_pulled_custom_role_stays_out_of_the_core_catalogs(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
root = Path(tmp)
|
|
_write(
|
|
root,
|
|
f"roles/web-app-wiki/{ROLE_FILE_META_MAIN}",
|
|
"galaxy_info:\n description: A wiki\n",
|
|
)
|
|
_write(
|
|
root,
|
|
f"roles/web-app-cst-demo/{ROLE_FILE_META_MAIN}",
|
|
"galaxy_info:\n description: A custom app\n",
|
|
)
|
|
|
|
messages = role_messages(root)
|
|
|
|
self.assertEqual(messages, [("role:web-app-wiki:description", "A wiki")])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|