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