Use more state attribute name constants (#40428)

This commit is contained in:
Ville Skyttä authored and GitHub committed 2020-09-21 23:03:39 +02:00
1 parent f78391ce2a
commit 5e90a4d000
36 files changed
+231 -156

No files matched your search

+6 -5
View File
@@ -5,6 +5,7 @@ import aiohttp
import pytest
from homeassistant import config_entries
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT
from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util
@@ -250,7 +251,7 @@ async def test_reading_is_sampled(hass, mock_get_station):
state = hass.states.get("sensor.my_station_water_level_stage")
assert state.state == "5"
assert state.attributes["unit_of_measurement"] == "m"
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == "m"
async def test_multiple_readings_are_sampled(hass, mock_get_station):
@@ -287,11 +288,11 @@ async def test_multiple_readings_are_sampled(hass, mock_get_station):
state = hass.states.get("sensor.my_station_water_level_stage")
assert state.state == "5"
assert state.attributes["unit_of_measurement"] == "m"
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == "m"
state = hass.states.get("sensor.my_station_water_level_second_stage")
assert state.state == "4"
assert state.attributes["unit_of_measurement"] == "m"
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == "m"
async def test_ignore_no_latest_reading(hass, mock_get_station):
@@ -327,7 +328,7 @@ async def test_ignore_no_latest_reading(hass, mock_get_station):
state = hass.states.get("sensor.my_station_water_level_stage")
assert state.state == "5"
assert state.attributes["unit_of_measurement"] == "m"
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == "m"
state = hass.states.get("sensor.my_station_water_level_second_stage")
assert state is None
@@ -357,7 +358,7 @@ async def test_mark_existing_as_unavailable_if_no_latest(hass, mock_get_station)
state = hass.states.get("sensor.my_station_water_level_stage")
assert state.state == "5"
assert state.attributes["unit_of_measurement"] == "m"
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == "m"
await poll(
{