mirror of
https://github.com/home-assistant/core.git
synced 2025-09-18 17:39:33 +00:00
Warn if unit_of_measurement is set on instances of SensorEntityDescription (#54867)
* Add class BaseEntityDescription without unit_of_measurement * Refactor according to review comments * Tweak * Fix offending integrations * Fix offending integrations
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""The test for sensor device automation."""
|
||||
from homeassistant.components.sensor import SensorEntityDescription
|
||||
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import dt as dt_util
|
||||
@@ -49,3 +50,12 @@ async def test_deprecated_last_reset(hass, caplog, enable_custom_integrations):
|
||||
"update your configuration if state_class is manually configured, otherwise "
|
||||
"report it to the custom component author."
|
||||
) in caplog.text
|
||||
|
||||
|
||||
async def test_deprecated_unit_of_measurement(hass, caplog, enable_custom_integrations):
|
||||
"""Test warning on deprecated unit_of_measurement."""
|
||||
SensorEntityDescription("catsensor", unit_of_measurement="cats")
|
||||
assert (
|
||||
"tests.components.sensor.test_init is setting 'unit_of_measurement' on an "
|
||||
"instance of SensorEntityDescription"
|
||||
) in caplog.text
|
||||
|
Reference in New Issue
Block a user