Files
mrb-netbox-topology-views/tests/test_metadata.py
T
MrBlakeandClaude Opus 5.5 cce6e21a09 feat(i18n): translate UI to English and German
Use English as source language for all user-visible strings, wrap them for
translation and ship a German catalog. Add a test that keeps the README's
NetBox range in sync with min_version/max_version.

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

38 lines
1.2 KiB
Python
Raw 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.
"""Keeps the NetBox range in README.md in sync with the PluginConfig."""
import ast
import re
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
def plugin_versions():
tree = ast.parse((ROOT / "netbox_topology_views" / "__init__.py").read_text())
values = {}
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) and target.id in ("min_version", "max_version"):
values[target.id] = node.value.value
return values["min_version"], values["max_version"]
def expected_range(min_version, max_version):
upper = re.sub(r"\.99$", ".x", max_version)
if min_version.endswith(".0") and upper == min_version[:-2] + ".x":
return f"`{upper}`"
return f"`{min_version}` – `{upper}`"
class MetadataTest(unittest.TestCase):
def test_readme_matches_plugin_config(self):
readme = (ROOT / "README.md").read_text()
expected = expected_range(*plugin_versions())
self.assertIn(f"| **NetBox** | {expected} |", readme)
self.assertIn(f"- NetBox {expected}", readme)
if __name__ == "__main__":
unittest.main()