Fix entity translations

This commit is contained in:
2026-07-21 14:45:24 +02:00
parent ba6a6ad044
commit 0f66b31769
10 changed files with 121 additions and 3 deletions
+26
View File
@@ -2,6 +2,7 @@
from __future__ import annotations
import json
from pathlib import Path
from unittest.mock import Mock
@@ -89,6 +90,31 @@ def test_total_sensor_count_and_unique_ids() -> None:
sensors = _sensors(FakeClient())
assert len(sensors) == 32
assert len({sensor.unique_id for sensor in sensors}) == len(sensors)
assert {sensor.unique_id for sensor in sensors} == {
f"arkteos_zuran4_{description.key}" for description in SENSOR_DESCRIPTIONS
}
def test_sensor_translation_keys_are_specific_and_translated() -> None:
translations_path = Path(__file__).parents[1] / "custom_components" / "arkteos" / "translations"
french_sensors = json.loads((translations_path / "fr.json").read_text())["entity"]["sensor"]
english_sensors = json.loads((translations_path / "en.json").read_text())["entity"]["sensor"]
translation_keys = [description.translation_key for description in SENSOR_DESCRIPTIONS]
assert all(translation_keys)
assert len(translation_keys) == len(set(translation_keys))
assert set(translation_keys) == set(french_sensors) == set(english_sensors)
assert all("name" in french_sensors[key] for key in translation_keys)
assert all("name" in english_sensors[key] for key in translation_keys)
assert not {"Temperature", "Power", "Frequency", "Duration", "Pressure", "Voltage", "Volume flow rate"} & {
english_sensors[key]["name"] for key in translation_keys
}
def test_entities_expose_their_description_translation_key() -> None:
sensors = _sensors(FakeClient())
assert all(sensor.has_entity_name for sensor in sensors)
assert all(sensor.translation_key == sensor.entity_description.translation_key for sensor in sensors)
def test_all_node_red_keys_are_described() -> None: