This repository has been archived on 2026-11-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
MrBlakeandClaude Opus 5.5 e9d9b59d16 feat: translate UI to English with German locale
Use English source strings wrapped for gettext, ship a German catalogue, and check that README and package metadata match the PluginConfig.

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

58 lines
2.1 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.
"""Keep README and packaging metadata in sync with the PluginConfig.
Runs without NetBox: `python -m unittest discover -s tests`.
"""
import ast
import re
import tomllib
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def plugin_config():
tree = ast.parse((ROOT / "netbox_better_ips" / "__init__.py").read_text())
return {
node.targets[0].id: node.value.value
for node in ast.walk(tree)
if isinstance(node, ast.Assign)
and isinstance(node.targets[0], ast.Name)
and isinstance(node.value, ast.Constant)
}
def readme_range(max_version):
# max_version "4.7.99" is written as "4.7.x" in the README
major_minor, patch = max_version.rsplit(".", 1)
return major_minor + ".x" if patch == "99" else max_version
class MetadataTest(unittest.TestCase):
def setUp(self):
self.config = plugin_config()
self.readme = (ROOT / "README.md").read_text()
def test_readme_netbox_range_matches_plugin_config(self):
expected = f"`{self.config['min_version']}` – `{readme_range(self.config['max_version'])}`"
info_row = re.search(r"^\| \*\*NetBox\*\* \| (.+?) \|$", self.readme, re.M)
self.assertIsNotNone(info_row, "README info table has no NetBox row")
self.assertEqual(info_row.group(1), expected)
compatibility = self.readme.split("## Compatibility", 1)[1].split("\n## ", 1)[0]
self.assertIn(f"NetBox {expected}", compatibility)
def test_package_version_matches_plugin_config(self):
project = tomllib.loads((ROOT / "pyproject.toml").read_text())["project"]
self.assertEqual(project["version"], self.config["__version__"])
def test_translations_are_shipped(self):
package_data = tomllib.loads((ROOT / "pyproject.toml").read_text())["tool"]["setuptools"][
"package-data"
]["netbox_better_ips"]
self.assertIn("locale/*/LC_MESSAGES/*.mo", package_data)
self.assertTrue((ROOT / "netbox_better_ips/locale/de/LC_MESSAGES/django.mo").is_file())
if __name__ == "__main__":
unittest.main()