1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-25 19:29:04 +01:00

Align number unit converters with sensor (#162662)

This commit is contained in:
Abílio Costa
2026-02-11 22:07:04 +00:00
committed by GitHub
parent db55dfe3c7
commit fd78e35a86
3 changed files with 71 additions and 11 deletions

View File

@@ -14,6 +14,7 @@ import pytest
from homeassistant.components import sensor
from homeassistant.components.number import (
AMBIGUOUS_UNITS as NUMBER_AMBIGUOUS_UNITS,
UNIT_CONVERTERS as NUMBER_UNIT_CONVERTERS,
NumberDeviceClass,
)
from homeassistant.components.sensor import (
@@ -2118,6 +2119,16 @@ def test_device_classes_aligned() -> None:
assert getattr(SensorDeviceClass, device_class.name).value == device_class.value
def test_unit_converters_aligned() -> None:
"""Make sure all number unit converters are also available in sensor converters."""
assert len(NUMBER_UNIT_CONVERTERS) == len(UNIT_CONVERTERS)
for device_class, converter in NUMBER_UNIT_CONVERTERS.items():
assert device_class.value in UNIT_CONVERTERS
assert UNIT_CONVERTERS[device_class.value] == converter
async def test_value_unknown_in_enumeration(
hass: HomeAssistant,
caplog: pytest.LogCaptureFixture,