Use UNIT_PERCENTAGE constant (#34054)
This commit is contained in:
1 parent
4f50b858d0
commit
9f713dac7f
6 files changed
+27
-19
No files matched your search
@@ -1,6 +1,6 @@
|
||||
"""The sensor tests for the august platform."""
|
||||
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
from homeassistant.const import STATE_UNAVAILABLE, UNIT_PERCENTAGE
|
||||
|
||||
from tests.components.august.mocks import (
|
||||
_create_august_with_devices,
|
||||
@@ -20,7 +20,10 @@ async def test_create_doorbell(hass):
|
||||
"sensor.k98gidt45gul_name_battery"
|
||||
)
|
||||
assert sensor_k98gidt45gul_name_battery.state == "96"
|
||||
assert sensor_k98gidt45gul_name_battery.attributes["unit_of_measurement"] == "%"
|
||||
assert (
|
||||
sensor_k98gidt45gul_name_battery.attributes["unit_of_measurement"]
|
||||
== UNIT_PERCENTAGE
|
||||
)
|
||||
|
||||
|
||||
async def test_create_doorbell_offline(hass):
|
||||
@@ -31,7 +34,9 @@ async def test_create_doorbell_offline(hass):
|
||||
|
||||
sensor_tmt100_name_battery = hass.states.get("sensor.tmt100_name_battery")
|
||||
assert sensor_tmt100_name_battery.state == "81"
|
||||
assert sensor_tmt100_name_battery.attributes["unit_of_measurement"] == "%"
|
||||
assert (
|
||||
sensor_tmt100_name_battery.attributes["unit_of_measurement"] == UNIT_PERCENTAGE
|
||||
)
|
||||
|
||||
entry = entity_registry.async_get("sensor.tmt100_name_battery")
|
||||
assert entry
|
||||
@@ -63,7 +68,7 @@ async def test_create_lock_with_linked_keypad(hass):
|
||||
sensor_a6697750d607098bae8d6baa11ef8063_name_battery.attributes[
|
||||
"unit_of_measurement"
|
||||
]
|
||||
== "%"
|
||||
== UNIT_PERCENTAGE
|
||||
)
|
||||
entry = entity_registry.async_get(
|
||||
"sensor.a6697750d607098bae8d6baa11ef8063_name_battery"
|
||||
@@ -73,7 +78,7 @@ async def test_create_lock_with_linked_keypad(hass):
|
||||
|
||||
state = hass.states.get("sensor.front_door_lock_keypad_battery")
|
||||
assert state.state == "60"
|
||||
assert state.attributes["unit_of_measurement"] == "%"
|
||||
assert state.attributes["unit_of_measurement"] == UNIT_PERCENTAGE
|
||||
entry = entity_registry.async_get("sensor.front_door_lock_keypad_battery")
|
||||
assert entry
|
||||
assert entry.unique_id == "5bc65c24e6ef2a263e1450a8_linked_keypad_battery"
|
||||
@@ -93,7 +98,7 @@ async def test_create_lock_with_low_battery_linked_keypad(hass):
|
||||
sensor_a6697750d607098bae8d6baa11ef8063_name_battery.attributes[
|
||||
"unit_of_measurement"
|
||||
]
|
||||
== "%"
|
||||
== UNIT_PERCENTAGE
|
||||
)
|
||||
entry = entity_registry.async_get(
|
||||
"sensor.a6697750d607098bae8d6baa11ef8063_name_battery"
|
||||
@@ -103,7 +108,7 @@ async def test_create_lock_with_low_battery_linked_keypad(hass):
|
||||
|
||||
state = hass.states.get("sensor.front_door_lock_keypad_battery")
|
||||
assert state.state == "10"
|
||||
assert state.attributes["unit_of_measurement"] == "%"
|
||||
assert state.attributes["unit_of_measurement"] == UNIT_PERCENTAGE
|
||||
entry = entity_registry.async_get("sensor.front_door_lock_keypad_battery")
|
||||
assert entry
|
||||
assert entry.unique_id == "5bc65c24e6ef2a263e1450a8_linked_keypad_battery"
|
||||
|
||||
Reference in new issue
Block a user