mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
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:
@@ -4,7 +4,6 @@ from datetime import timedelta
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from homeassistant.core import CoreState, State
|
||||
from homeassistant.const import MATCH_ALL
|
||||
from homeassistant import setup
|
||||
from homeassistant.components.binary_sensor import template
|
||||
@@ -12,11 +11,9 @@ from homeassistant.exceptions import TemplateError
|
||||
from homeassistant.helpers import template as template_hlpr
|
||||
from homeassistant.util.async import run_callback_threadsafe
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.helpers.restore_state import DATA_RESTORE_CACHE
|
||||
|
||||
from tests.common import (
|
||||
get_test_home_assistant, assert_setup_component, mock_component,
|
||||
async_fire_time_changed)
|
||||
get_test_home_assistant, assert_setup_component, async_fire_time_changed)
|
||||
|
||||
|
||||
class TestBinarySensorTemplate(unittest.TestCase):
|
||||
@@ -169,41 +166,6 @@ class TestBinarySensorTemplate(unittest.TestCase):
|
||||
run_callback_threadsafe(self.hass.loop, vs.async_check_state).result()
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_restore_state(hass):
|
||||
"""Ensure states are restored on startup."""
|
||||
hass.data[DATA_RESTORE_CACHE] = {
|
||||
'binary_sensor.test': State('binary_sensor.test', 'on'),
|
||||
}
|
||||
|
||||
hass.state = CoreState.starting
|
||||
mock_component(hass, 'recorder')
|
||||
|
||||
config = {
|
||||
'binary_sensor': {
|
||||
'platform': 'template',
|
||||
'sensors': {
|
||||
'test': {
|
||||
'friendly_name': 'virtual thingy',
|
||||
'value_template':
|
||||
"{{ states.sensor.test_state.state == 'on' }}",
|
||||
'device_class': 'motion',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
yield from setup.async_setup_component(hass, 'binary_sensor', config)
|
||||
|
||||
state = hass.states.get('binary_sensor.test')
|
||||
assert state.state == 'on'
|
||||
|
||||
yield from hass.async_start()
|
||||
yield from hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get('binary_sensor.test')
|
||||
assert state.state == 'off'
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_template_delay_on(hass):
|
||||
"""Test binary sensor template delay on."""
|
||||
|
||||
Reference in New Issue
Block a user