mirror of
https://github.com/home-assistant/core.git
synced 2025-12-25 05:26:47 +00:00
Extend state class sensor warnings with expected values (#87294)
This commit is contained in:
@@ -9,6 +9,7 @@ import pytest
|
||||
|
||||
from homeassistant.components.number import NumberDeviceClass
|
||||
from homeassistant.components.sensor import (
|
||||
DEVICE_CLASS_STATE_CLASSES,
|
||||
DEVICE_CLASS_UNITS,
|
||||
SensorDeviceClass,
|
||||
SensorStateClass,
|
||||
@@ -1637,9 +1638,14 @@ async def test_device_classes_with_invalid_state_class(
|
||||
assert await async_setup_component(hass, "sensor", {"sensor": {"platform": "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
classes = DEVICE_CLASS_STATE_CLASSES.get(device_class, set())
|
||||
one_of = ", ".join(f"'{value.value}'" for value in classes)
|
||||
expected = f"None or one of {one_of}" if classes else "None"
|
||||
|
||||
assert (
|
||||
"is using state class 'INVALID!' which is impossible considering device "
|
||||
f"class ('{device_class}') it is using"
|
||||
f"class ('{device_class}') it is using; "
|
||||
f"expected {expected}"
|
||||
) in caplog.text
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user