mirror of
https://github.com/home-assistant/core.git
synced 2025-08-15 18:41:44 +02:00
Use enums in helpers tests (#62141)
This commit is contained in:
@@ -6,7 +6,7 @@ import pytest
|
||||
|
||||
from homeassistant.components import sun
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.sensor import DEVICE_CLASS_TIMESTAMP
|
||||
from homeassistant.components.sensor import SensorDeviceClass
|
||||
from homeassistant.const import (
|
||||
ATTR_DEVICE_CLASS,
|
||||
CONF_CONDITION,
|
||||
@@ -854,12 +854,12 @@ async def test_time_using_sensor(hass):
|
||||
hass.states.async_set(
|
||||
"sensor.am",
|
||||
"2021-06-03 13:00:00.000000+00:00", # 6 am local time
|
||||
{ATTR_DEVICE_CLASS: DEVICE_CLASS_TIMESTAMP},
|
||||
{ATTR_DEVICE_CLASS: SensorDeviceClass.TIMESTAMP},
|
||||
)
|
||||
hass.states.async_set(
|
||||
"sensor.pm",
|
||||
"2020-06-01 01:00:00.000000+00:00", # 6 pm local time
|
||||
{ATTR_DEVICE_CLASS: DEVICE_CLASS_TIMESTAMP},
|
||||
{ATTR_DEVICE_CLASS: SensorDeviceClass.TIMESTAMP},
|
||||
)
|
||||
hass.states.async_set(
|
||||
"sensor.no_device_class",
|
||||
@@ -868,7 +868,7 @@ async def test_time_using_sensor(hass):
|
||||
hass.states.async_set(
|
||||
"sensor.invalid_timestamp",
|
||||
"This is not a timestamp",
|
||||
{ATTR_DEVICE_CLASS: DEVICE_CLASS_TIMESTAMP},
|
||||
{ATTR_DEVICE_CLASS: SensorDeviceClass.TIMESTAMP},
|
||||
)
|
||||
|
||||
with patch(
|
||||
|
@@ -1,7 +1,7 @@
|
||||
"""Test significant change helper."""
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.sensor import DEVICE_CLASS_BATTERY
|
||||
from homeassistant.components.sensor import SensorDeviceClass
|
||||
from homeassistant.const import ATTR_DEVICE_CLASS, STATE_UNAVAILABLE, STATE_UNKNOWN
|
||||
from homeassistant.core import State
|
||||
from homeassistant.helpers import significant_change
|
||||
@@ -26,7 +26,7 @@ async def checker_fixture(hass):
|
||||
async def test_signicant_change(hass, checker):
|
||||
"""Test initialize helper works."""
|
||||
ent_id = "test_domain.test_entity"
|
||||
attrs = {ATTR_DEVICE_CLASS: DEVICE_CLASS_BATTERY}
|
||||
attrs = {ATTR_DEVICE_CLASS: SensorDeviceClass.BATTERY}
|
||||
|
||||
assert checker.async_is_significant_change(State(ent_id, "100", attrs))
|
||||
|
||||
@@ -50,7 +50,7 @@ async def test_signicant_change(hass, checker):
|
||||
async def test_significant_change_extra(hass, checker):
|
||||
"""Test extra significant checker works."""
|
||||
ent_id = "test_domain.test_entity"
|
||||
attrs = {ATTR_DEVICE_CLASS: DEVICE_CLASS_BATTERY}
|
||||
attrs = {ATTR_DEVICE_CLASS: SensorDeviceClass.BATTERY}
|
||||
|
||||
assert checker.async_is_significant_change(State(ent_id, "100", attrs), extra_arg=1)
|
||||
assert checker.async_is_significant_change(State(ent_id, "200", attrs), extra_arg=1)
|
||||
|
Reference in New Issue
Block a user