Files
NetBox-Export/tests/test_metadata.py
MrBlakeandClaude Opus 5.5 72e04fe086 feat(i18n): translate UI and import messages to English with German catalogue
English is now the source language for the dashboard, forms, menu, JavaScript progress texts and all import/export messages; a complete German catalogue ships as package data. Tenant-error detection also accepts the error code and the active-language message of netbox_utilities, and no longer imports netbox_utilities when it is installed but not enabled. A test keeps the README NetBox range in sync with min_version/max_version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 21:26:52 +01:00

39 lines
1.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import ast
import re
from pathlib import Path
ROOT = Path(__file__).parents[1]
def _plugin_versions():
tree = ast.parse((ROOT / "netbox_export" / "__init__.py").read_text(encoding="utf-8"))
values = {
target.id: node.value.value
for node in ast.walk(tree)
if isinstance(node, ast.Assign) and isinstance(node.value, ast.Constant)
for target in node.targets
if isinstance(target, ast.Name)
}
return values["min_version"], values["max_version"]
def test_readme_netbox_range_matches_plugin_config():
min_version, max_version = _plugin_versions()
major, minor, patch = max_version.split(".")
upper = f"{major}.{minor}.x" if patch == "99" else max_version # 4.7.99 is documented as 4.7.x
expected = f"`{min_version}` – `{upper}`"
readme = (ROOT / "README.md").read_text(encoding="utf-8")
assert f"| **NetBox** | {expected} |" in readme
assert f"- NetBox {expected}" in readme
def test_german_catalog_is_complete():
po = ROOT / "netbox_export" / "locale" / "de" / "LC_MESSAGES" / "django.po"
content = po.read_text(encoding="utf-8")
entries = re.findall(r'^msgid ((?:".*"\n)+)msgstr ((?:".*"\n?)+)', content, re.MULTILINE)
assert "#, fuzzy" not in content
assert [msgid for msgid, msgstr in entries[1:] if msgstr.strip() == '""'] == []
assert po.with_suffix(".mo").is_file()