Async bootstrap / component init (#3991)
* Async bootstrap * Adress comments * Fix tests * More fixes * Tests fixes
This commit is contained in:
1 parent
d9999f36e8
commit
d5368f6f78
54 files changed
+1431
-1131
No files matched your search
@@ -1,5 +1,6 @@
|
||||
"""The testd for Core components."""
|
||||
# pylint: disable=protected-access,too-many-public-methods
|
||||
import asyncio
|
||||
import unittest
|
||||
from unittest.mock import patch, Mock
|
||||
|
||||
@@ -11,6 +12,7 @@ from homeassistant.const import (
|
||||
STATE_ON, STATE_OFF, SERVICE_TURN_ON, SERVICE_TURN_OFF, SERVICE_TOGGLE)
|
||||
import homeassistant.components as comps
|
||||
from homeassistant.helpers import entity
|
||||
from homeassistant.util.async import run_coroutine_threadsafe
|
||||
|
||||
from tests.common import (
|
||||
get_test_home_assistant, mock_service, patch_yaml_files)
|
||||
@@ -22,7 +24,9 @@ class TestComponentsCore(unittest.TestCase):
|
||||
def setUp(self): # pylint: disable=invalid-name
|
||||
"""Setup things to be run when tests are started."""
|
||||
self.hass = get_test_home_assistant()
|
||||
self.assertTrue(comps.setup(self.hass, {}))
|
||||
self.assertTrue(run_coroutine_threadsafe(
|
||||
comps.async_setup(self.hass, {}), self.hass.loop
|
||||
).result())
|
||||
|
||||
self.hass.states.set('light.Bowl', STATE_ON)
|
||||
self.hass.states.set('light.Ceiling', STATE_OFF)
|
||||
@@ -66,6 +70,7 @@ class TestComponentsCore(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(calls))
|
||||
|
||||
@asyncio.coroutine
|
||||
@patch('homeassistant.core.ServiceRegistry.call')
|
||||
def test_turn_on_to_not_block_for_domains_without_service(self, mock_call):
|
||||
"""Test if turn_on is blocking domain with no service."""
|
||||
@@ -78,7 +83,7 @@ class TestComponentsCore(unittest.TestCase):
|
||||
'entity_id': ['light.test', 'sensor.bla', 'light.bla']
|
||||
})
|
||||
service = self.hass.services._services['homeassistant']['turn_on']
|
||||
service.func(service_call)
|
||||
yield from service.func(service_call)
|
||||
|
||||
self.assertEqual(2, mock_call.call_count)
|
||||
self.assertEqual(
|
||||
@@ -131,7 +136,7 @@ class TestComponentsCore(unittest.TestCase):
|
||||
|
||||
@patch('homeassistant.config.os.path.isfile', Mock(return_value=True))
|
||||
@patch('homeassistant.components._LOGGER.error')
|
||||
@patch('homeassistant.config.process_ha_core_config')
|
||||
@patch('homeassistant.config.async_process_ha_core_config')
|
||||
def test_reload_core_with_wrong_conf(self, mock_process, mock_error):
|
||||
"""Test reload core conf service."""
|
||||
files = {
|
||||
|
||||
Reference in new issue
Block a user