core/tests/components/sma/test_sensor.py

20 lines
583 B
Python
Raw Normal View History

"""Test the sma sensor platform."""
from homeassistant.const import (
ATTR_UNIT_OF_MEASUREMENT,
ENERGY_KILO_WATT_HOUR,
POWER_WATT,
)
2019-08-19 20:10:35 +00:00
from . import MOCK_CUSTOM_SENSOR
2019-08-19 20:10:35 +00:00
async def test_sensors(hass, init_integration):
"""Test states of the sensors."""
2019-08-19 20:10:35 +00:00
state = hass.states.get("sensor.current_consumption")
assert state
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == POWER_WATT
2019-08-19 20:10:35 +00:00
state = hass.states.get(f"sensor.{MOCK_CUSTOM_SENSOR['name']}")
2019-08-19 20:10:35 +00:00
assert state
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ENERGY_KILO_WATT_HOUR