mirror of
https://github.com/home-assistant/core.git
synced 2025-11-13 04:50:17 +00:00
Use greek small letter mu "\u03bc" instead of micro sign "\u00B5" for micro unit prefix (alt 1) (#144853)
Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
@@ -11,8 +11,12 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
from homeassistant.components import sensor
|
||||
from homeassistant.components.number import NumberDeviceClass
|
||||
from homeassistant.components.number import (
|
||||
AMBIGUOUS_UNITS as NUMBER_AMBIGUOUS_UNITS,
|
||||
NumberDeviceClass,
|
||||
)
|
||||
from homeassistant.components.sensor import (
|
||||
AMBIGUOUS_UNITS as SENSOR_AMBIGUOUS_UNITS,
|
||||
DEVICE_CLASS_STATE_CLASSES,
|
||||
DEVICE_CLASS_UNITS,
|
||||
DOMAIN,
|
||||
@@ -159,12 +163,47 @@ async def test_temperature_conversion_wrong_device_class(
|
||||
assert await async_setup_component(hass, "sensor", {"sensor": {"platform": "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Check temperature is not converted
|
||||
# Check compatible unit is applied
|
||||
state = hass.states.get(entity0.entity_id)
|
||||
assert state.state == "0.0"
|
||||
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfTemperature.FAHRENHEIT
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("ambiguous_unit", "normalized_unit"),
|
||||
[
|
||||
(ambiguous_unit, normalized_unit)
|
||||
for ambiguous_unit, normalized_unit in sensor.AMBIGUOUS_UNITS.items()
|
||||
],
|
||||
)
|
||||
async def test_ambiguous_unit_of_measurement_compat(
|
||||
hass: HomeAssistant, ambiguous_unit: str, normalized_unit: str
|
||||
) -> None:
|
||||
"""Test ambiguous native_unit_of_measurement values are corrected."""
|
||||
entity0 = MockSensor(
|
||||
name="Test",
|
||||
native_value="0.0",
|
||||
native_unit_of_measurement=ambiguous_unit,
|
||||
)
|
||||
setup_test_component_platform(hass, sensor.DOMAIN, [entity0])
|
||||
|
||||
assert await async_setup_component(hass, "sensor", {"sensor": {"platform": "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Check temperature is not converted
|
||||
state = hass.states.get(entity0.entity_id)
|
||||
assert state.state == "0.0"
|
||||
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == normalized_unit
|
||||
|
||||
|
||||
def test_ambiguous_units_of_measurement_aligned() -> None:
|
||||
"""Make sure all ambiguous UOM for sensor are also available for number."""
|
||||
|
||||
for ambiguous_unit, unit in SENSOR_AMBIGUOUS_UNITS.items():
|
||||
assert ambiguous_unit in NUMBER_AMBIGUOUS_UNITS
|
||||
assert NUMBER_AMBIGUOUS_UNITS[ambiguous_unit] == unit
|
||||
|
||||
|
||||
@pytest.mark.parametrize("state_class", ["measurement", "total_increasing"])
|
||||
async def test_deprecated_last_reset(
|
||||
hass: HomeAssistant,
|
||||
|
||||
Reference in New Issue
Block a user