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 TekSavvy sensor platform."""
|
||||
from homeassistant.bootstrap import async_setup_component
|
||||
from homeassistant.components.teksavvy.sensor import TekSavvyData
|
||||
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
|
||||
|
||||
|
||||
@@ -47,43 +52,43 @@ async def test_capped_setup(hass, aioclient_mock):
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("sensor.teksavvy_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.teksavvy_off_peak_download")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "36.24"
|
||||
|
||||
state = hass.states.get("sensor.teksavvy_off_peak_upload")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "1.58"
|
||||
|
||||
state = hass.states.get("sensor.teksavvy_off_peak_total")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "37.82"
|
||||
|
||||
state = hass.states.get("sensor.teksavvy_on_peak_download")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "226.75"
|
||||
|
||||
state = hass.states.get("sensor.teksavvy_on_peak_upload")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "8.82"
|
||||
|
||||
state = hass.states.get("sensor.teksavvy_on_peak_total")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "235.57"
|
||||
|
||||
state = hass.states.get("sensor.teksavvy_usage_ratio")
|
||||
assert state.attributes.get("unit_of_measurement") == PERCENTAGE
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
||||
assert state.state == "56.69"
|
||||
|
||||
state = hass.states.get("sensor.teksavvy_usage")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "226.75"
|
||||
|
||||
state = hass.states.get("sensor.teksavvy_remaining")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "173.25"
|
||||
|
||||
|
||||
@@ -129,43 +134,43 @@ async def test_unlimited_setup(hass, aioclient_mock):
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("sensor.teksavvy_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.teksavvy_off_peak_download")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "36.24"
|
||||
|
||||
state = hass.states.get("sensor.teksavvy_off_peak_upload")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "1.58"
|
||||
|
||||
state = hass.states.get("sensor.teksavvy_off_peak_total")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "37.82"
|
||||
|
||||
state = hass.states.get("sensor.teksavvy_on_peak_download")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "226.75"
|
||||
|
||||
state = hass.states.get("sensor.teksavvy_on_peak_upload")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "8.82"
|
||||
|
||||
state = hass.states.get("sensor.teksavvy_on_peak_total")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "235.57"
|
||||
|
||||
state = hass.states.get("sensor.teksavvy_usage")
|
||||
assert state.attributes.get("unit_of_measurement") == DATA_GIGABYTES
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == DATA_GIGABYTES
|
||||
assert state.state == "226.75"
|
||||
|
||||
state = hass.states.get("sensor.teksavvy_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.teksavvy_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