Fix counter with empty config (#30454)

This commit is contained in:
Phil Bruckner authored and Paulus Schoutsen committed 2020-01-04 00:03:54 +01:00
1 parent b75aa7eb3a
commit d6e230e66b
2 files changed
+24 -8

No files matched your search

+11 -1
View File
@@ -3,11 +3,15 @@
import logging
from homeassistant.components.counter import (
ATTR_INITIAL,
ATTR_STEP,
CONF_ICON,
CONF_INITIAL,
CONF_NAME,
CONF_RESTORE,
CONF_STEP,
DEFAULT_INITIAL,
DEFAULT_STEP,
DOMAIN,
)
from homeassistant.const import ATTR_FRIENDLY_NAME, ATTR_ICON
@@ -48,6 +52,7 @@ async def test_config_options(hass):
CONF_RESTORE: False,
CONF_STEP: 5,
},
"test_3": None,
}
}
@@ -56,14 +61,16 @@ async def test_config_options(hass):
_LOGGER.debug("ENTITIES: %s", hass.states.async_entity_ids())
assert count_start + 2 == len(hass.states.async_entity_ids())
assert count_start + 3 == len(hass.states.async_entity_ids())
await hass.async_block_till_done()
state_1 = hass.states.get("counter.test_1")
state_2 = hass.states.get("counter.test_2")
state_3 = hass.states.get("counter.test_3")
assert state_1 is not None
assert state_2 is not None
assert state_3 is not None
assert 0 == int(state_1.state)
assert ATTR_ICON not in state_1.attributes
@@ -73,6 +80,9 @@ async def test_config_options(hass):
assert "Hello World" == state_2.attributes.get(ATTR_FRIENDLY_NAME)
assert "mdi:work" == state_2.attributes.get(ATTR_ICON)
assert DEFAULT_INITIAL == state_3.attributes.get(ATTR_INITIAL)
assert DEFAULT_STEP == state_3.attributes.get(ATTR_STEP)
async def test_methods(hass):
"""Test increment, decrement, and reset methods."""