Add and use percentage constant (#32094)

* Add and use percentage constant

* Fix pylint error and broken test
This commit is contained in:
springstan 2020-02-28 20:46:48 +01:00 committed by GitHub
parent c7f128f286
commit f1a0ca7cd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
155 changed files with 735 additions and 459 deletions

View file

@ -12,7 +12,7 @@ from homeassistant.components.rflink import (
EVENT_KEY_SENSOR,
TMP_ENTITY,
)
from homeassistant.const import STATE_UNKNOWN
from homeassistant.const import STATE_UNKNOWN, UNIT_PERCENTAGE
from tests.components.rflink.test_init import mock_rflink
@ -141,7 +141,12 @@ async def test_aliases(hass, monkeypatch):
# test event for config sensor
event_callback(
{"id": "test_alias_02_0", "sensor": "humidity", "value": 65, "unit": "%"}
{
"id": "test_alias_02_0",
"sensor": "humidity",
"value": 65,
"unit": UNIT_PERCENTAGE,
}
)
await hass.async_block_till_done()
@ -149,7 +154,7 @@ async def test_aliases(hass, monkeypatch):
updated_sensor = hass.states.get("sensor.test_02")
assert updated_sensor
assert updated_sensor.state == "65"
assert updated_sensor.attributes["unit_of_measurement"] == "%"
assert updated_sensor.attributes["unit_of_measurement"] == UNIT_PERCENTAGE
async def test_race_condition(hass, monkeypatch):