Fix async probs (#9924)

* Update entity.py

* Update entity_component.py

* Update entity_component.py

* Update __init__.py

* Update entity_component.py

* Update entity_component.py

* Update entity.py

* cleanup entity

* Update entity_component.py

* Update entity_component.py

* Fix names & comments / fix tests

* Revert deadlock protection

* Add tests for entity

* Add test fix name

* Update other code

* Fix lint

* Remove restore state from template entities

* Lint
This commit is contained in:
Pascal Vizeli authored and GitHub committed 2017-10-19 10:56:25 +02:00
1 parent 6cce934f72
commit c1b197419d
24 files changed
+356 -362

No files matched your search

+2 -40
View File
@@ -1,12 +1,7 @@
"""The test for the Template sensor platform."""
import asyncio
from homeassistant.setup import setup_component
from homeassistant.core import CoreState, State
from homeassistant.setup import setup_component, async_setup_component
from homeassistant.helpers.restore_state import DATA_RESTORE_CACHE
from tests.common import (
get_test_home_assistant, assert_setup_component, mock_component)
from tests.common import get_test_home_assistant, assert_setup_component
class TestTemplateSensor:
@@ -188,36 +183,3 @@ class TestTemplateSensor:
self.hass.block_till_done()
assert self.hass.states.all() == []
@asyncio.coroutine
def test_restore_state(hass):
"""Ensure states are restored on startup."""
hass.data[DATA_RESTORE_CACHE] = {
'sensor.test_template_sensor':
State('sensor.test_template_sensor', 'It Test.'),
}
hass.state = CoreState.starting
mock_component(hass, 'recorder')
yield from async_setup_component(hass, 'sensor', {
'sensor': {
'platform': 'template',
'sensors': {
'test_template_sensor': {
'value_template':
"It {{ states.sensor.test_state.state }}."
}
}
}
})
state = hass.states.get('sensor.test_template_sensor')
assert state.state == 'It Test.'
yield from hass.async_start()
yield from hass.async_block_till_done()
state = hass.states.get('sensor.test_template_sensor')
assert state.state == 'It .'