Restore input_select and test helper proposal (#6148)
* Restore input_select and test helper proposal * DB still active
This commit is contained in:
1 parent
8983b826c4
commit
aee8758fc1
5 files changed
+135
-22
No files matched your search
@@ -1,10 +1,12 @@
|
||||
"""The tests for the Input select component."""
|
||||
# pylint: disable=protected-access
|
||||
import asyncio
|
||||
import unittest
|
||||
|
||||
from tests.common import get_test_home_assistant
|
||||
from tests.common import get_test_home_assistant, mock_restore_cache
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.core import State
|
||||
from homeassistant.bootstrap import setup_component, async_setup_component
|
||||
from homeassistant.components.input_select import (
|
||||
ATTR_OPTIONS, DOMAIN, SERVICE_SET_OPTIONS,
|
||||
select_option, select_next, select_previous)
|
||||
@@ -211,3 +213,35 @@ class TestInputSelect(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(entity_id)
|
||||
self.assertEqual('test2', state.state)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_restore_state(hass):
|
||||
"""Ensure states are restored on startup."""
|
||||
mock_restore_cache(hass, (
|
||||
State('input_select.s1', 'last option'),
|
||||
State('input_select.s2', 'bad option'),
|
||||
))
|
||||
|
||||
options = {
|
||||
'options': [
|
||||
'first option',
|
||||
'middle option',
|
||||
'last option',
|
||||
],
|
||||
'initial': 'middle option',
|
||||
}
|
||||
|
||||
yield from async_setup_component(hass, DOMAIN, {
|
||||
DOMAIN: {
|
||||
's1': options,
|
||||
's2': options,
|
||||
}})
|
||||
|
||||
state = hass.states.get('input_select.s1')
|
||||
assert state
|
||||
assert state.state == 'last option'
|
||||
|
||||
state = hass.states.get('input_select.s2')
|
||||
assert state
|
||||
assert state.state == 'middle option'
|
||||
Reference in new issue
Block a user