Fix timer with empty config (#30463)

This commit is contained in:
Phil Bruckner authored and Paulus Schoutsen committed 2020-01-04 23:01:58 +01:00
1 parent 6c89b6c5a2
commit e233dd7cbe
2 files changed
+21 -11

No files matched your search

+8 -1
View File
@@ -11,6 +11,7 @@ from homeassistant.components.timer import (
CONF_DURATION,
CONF_ICON,
CONF_NAME,
DEFAULT_DURATION,
DOMAIN,
EVENT_TIMER_CANCELLED,
EVENT_TIMER_FINISHED,
@@ -63,20 +64,23 @@ async def test_config_options(hass):
CONF_ICON: "mdi:work",
CONF_DURATION: 10,
},
"test_3": None,
}
}
assert await async_setup_component(hass, "timer", config)
await hass.async_block_till_done()
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("timer.test_1")
state_2 = hass.states.get("timer.test_2")
state_3 = hass.states.get("timer.test_3")
assert state_1 is not None
assert state_2 is not None
assert state_3 is not None
assert STATUS_IDLE == state_1.state
assert ATTR_ICON not in state_1.attributes
@@ -87,6 +91,9 @@ async def test_config_options(hass):
assert "mdi:work" == state_2.attributes.get(ATTR_ICON)
assert "0:00:10" == state_2.attributes.get(ATTR_DURATION)
assert STATUS_IDLE == state_3.state
assert str(DEFAULT_DURATION) == state_3.attributes.get(CONF_DURATION)
async def test_methods_and_events(hass):
"""Test methods and events."""