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

+12 -6
View File
@@ -8,7 +8,12 @@ from homeassistant.components.demo.geo_location import (
DEFAULT_UPDATE_INTERVAL,
NUMBER_OF_DEMO_DEVICES,
)
from homeassistant.const import LENGTH_KILOMETERS
from homeassistant.const import (
ATTR_LATITUDE,
ATTR_LONGITUDE,
ATTR_UNIT_OF_MEASUREMENT,
LENGTH_KILOMETERS,
)
from homeassistant.setup import setup_component
import homeassistant.util.dt as dt_util
@@ -59,13 +64,14 @@ class TestDemoPlatform(unittest.TestCase):
# ignore home zone state
continue
assert (
abs(state.attributes["latitude"] - self.hass.config.latitude) < 1.0
)
assert (
abs(state.attributes["longitude"] - self.hass.config.longitude)
abs(state.attributes[ATTR_LATITUDE] - self.hass.config.latitude)
< 1.0
)
assert state.attributes["unit_of_measurement"] == LENGTH_KILOMETERS
assert (
abs(state.attributes[ATTR_LONGITUDE] - self.hass.config.longitude)
< 1.0
)
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == LENGTH_KILOMETERS
# Update (replaces 1 device).
fire_time_changed(self.hass, utcnow + DEFAULT_UPDATE_INTERVAL)
+2 -1
View File
@@ -3,6 +3,7 @@ import pytest
import voluptuous as vol
import homeassistant.components.media_player as mp
from homeassistant.const import ATTR_SUPPORTED_FEATURES
from homeassistant.helpers.aiohttp_client import DATA_CLIENTSESSION
from homeassistant.setup import async_setup_component
@@ -203,7 +204,7 @@ async def test_seek(hass, mock_media_seek):
await hass.async_block_till_done()
ent_id = "media_player.living_room"
state = hass.states.get(ent_id)
assert state.attributes["supported_features"] & mp.SUPPORT_SEEK
assert state.attributes[ATTR_SUPPORTED_FEATURES] & mp.SUPPORT_SEEK
assert not mock_media_seek.called
with pytest.raises(vol.Invalid):
await common.async_media_seek(hass, None, ent_id)