Correct device class in sql tests (#107663)

This commit is contained in:
Jan-Philipp Benecke 2024-01-09 16:30:21 +01:00 committed by GitHub
parent 1a6418d361
commit 33dd6f66e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View file

@ -18,6 +18,7 @@ from homeassistant.const import (
CONF_UNIQUE_ID,
CONF_UNIT_OF_MEASUREMENT,
CONF_VALUE_TEMPLATE,
UnitOfInformation,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.trigger_template_entity import (
@ -170,10 +171,10 @@ YAML_CONFIG = {
CONF_NAME: "Get Value",
CONF_QUERY: "SELECT 5 as value",
CONF_COLUMN_NAME: "value",
CONF_UNIT_OF_MEASUREMENT: "MiB",
CONF_UNIT_OF_MEASUREMENT: UnitOfInformation.MEBIBYTES,
CONF_UNIQUE_ID: "unique_id_12345",
CONF_VALUE_TEMPLATE: "{{ value }}",
CONF_DEVICE_CLASS: SensorDeviceClass.DATA_RATE,
CONF_DEVICE_CLASS: SensorDeviceClass.DATA_SIZE,
CONF_STATE_CLASS: SensorStateClass.MEASUREMENT,
}
}

View file

@ -20,6 +20,7 @@ from homeassistant.const import (
CONF_UNIQUE_ID,
STATE_UNAVAILABLE,
STATE_UNKNOWN,
UnitOfInformation,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import issue_registry as ir
@ -401,9 +402,9 @@ async def test_attributes_from_yaml_setup(
state = hass.states.get("sensor.get_value")
assert state.state == "5"
assert state.attributes["device_class"] == SensorDeviceClass.DATA_RATE
assert state.attributes["device_class"] == SensorDeviceClass.DATA_SIZE
assert state.attributes["state_class"] == SensorStateClass.MEASUREMENT
assert state.attributes["unit_of_measurement"] == "MiB"
assert state.attributes["unit_of_measurement"] == UnitOfInformation.MEBIBYTES
async def test_binary_data_from_yaml_setup(