"""Согласованность strings.json / translations en/ru.""" from __future__ import annotations import json import pathlib ROOT = pathlib.Path(__file__).resolve().parents[3] COMPONENT = ROOT / "custom_components" / "fglair" def _keys(node, prefix: str = "") -> set[str]: keys: set[str] = set() if isinstance(node, dict): for key, value in node.items(): keys.add(prefix + key) keys |= _keys(value, prefix + key + ".") return keys def test_en_matches_strings(): strings = json.loads((COMPONENT / "strings.json").read_text()) english = json.loads((COMPONENT / "translations" / "en.json").read_text()) assert strings == english def test_ru_covers_all_keys(): strings = json.loads((COMPONENT / "strings.json").read_text()) russian = json.loads((COMPONENT / "translations" / "ru.json").read_text()) assert _keys(strings) == _keys(russian)