Use more state attribute name constants (#40428)
This commit is contained in:
1 parent
f78391ce2a
commit
5e90a4d000
36 files changed
+231
-156
No files matched your search
@@ -1,7 +1,12 @@
|
||||
"""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, HTTP_NOT_FOUND, PERCENTAGE
|
||||
from homeassistant.const import (
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
DATA_GIGABYTES,
|
||||
HTTP_NOT_FOUND,
|
||||
PERCENTAGE,
|
||||
)
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
|
||||
@@ -53,51 +58,51 @@ async def test_capped_setup(hass, aioclient_mock):
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("sensor.start_ca_usage_ratio")
|
||||
assert state.attributes.get("unit_of_measurement") == PERCENTAGE
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
||||
assert state.state == "76.24"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_usage")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "304.95"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_data_limit")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "400"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_used_download")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "304.95"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_used_upload")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "6.48"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_used_total")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "311.43"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_grace_download")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "304.95"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_grace_upload")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "6.48"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_grace_total")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "311.43"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_total_download")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "304.95"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_total_upload")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "6.48"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_remaining")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "95.05"
|
||||
|
||||
|
||||
@@ -149,51 +154,51 @@ async def test_unlimited_setup(hass, aioclient_mock):
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("sensor.start_ca_usage_ratio")
|
||||
assert state.attributes.get("unit_of_measurement") == PERCENTAGE
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
||||
assert state.state == "0"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_usage")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "0.0"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_data_limit")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "inf"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_used_download")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "0.0"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_used_upload")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "0.0"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_used_total")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "0.0"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_grace_download")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "304.95"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_grace_upload")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "6.48"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_grace_total")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "311.43"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_total_download")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "304.95"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_total_upload")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "6.48"
|
||||
|
||||
state = hass.states.get("sensor.start_ca_remaining")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "inf"
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user