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

@ -1,7 +1,7 @@
"""Tests for the Start.ca sensor platform."""
from homeassistant.bootstrap import async_setup_component
from homeassistant.components.startca.sensor import StartcaData
from homeassistant.const import DATA_GIGABYTES
from homeassistant.const import DATA_GIGABYTES, UNIT_PERCENTAGE
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -52,7 +52,7 @@ async def test_capped_setup(hass, aioclient_mock):
await async_setup_component(hass, "sensor", {"sensor": config})
state = hass.states.get("sensor.start_ca_usage_ratio")
assert state.attributes.get("unit_of_measurement") == "%"
assert state.attributes.get("unit_of_measurement") == UNIT_PERCENTAGE
assert state.state == "76.24"
state = hass.states.get("sensor.start_ca_usage")
@ -147,7 +147,7 @@ async def test_unlimited_setup(hass, aioclient_mock):
await async_setup_component(hass, "sensor", {"sensor": config})
state = hass.states.get("sensor.start_ca_usage_ratio")
assert state.attributes.get("unit_of_measurement") == "%"
assert state.attributes.get("unit_of_measurement") == UNIT_PERCENTAGE
assert state.state == "0"
state = hass.states.get("sensor.start_ca_usage")