Async bootstrap / component init (#3991)

* Async bootstrap

* Adress comments

* Fix tests

* More fixes

* Tests fixes
This commit is contained in:
Pascal Vizeli authored and Paulus Schoutsen committed 2016-10-27 00:16:23 -07:00
1 parent d9999f36e8
commit d5368f6f78
54 files changed
+1431 -1131

No files matched your search

+7 -7
View File
@@ -30,7 +30,7 @@ light:
import json
import unittest
from homeassistant.bootstrap import _setup_component, setup_component
from homeassistant.bootstrap import setup_component
from homeassistant.const import STATE_ON, STATE_OFF, ATTR_ASSUMED_STATE
import homeassistant.components.light as light
from tests.common import (
@@ -67,7 +67,7 @@ class TestLightMQTTJSON(unittest.TestCase):
# pylint: disable=invalid-name
"""Test if there is no color and brightness if they aren't defined."""
self.hass.config.components = ['mqtt']
assert _setup_component(self.hass, light.DOMAIN, {
assert setup_component(self.hass, light.DOMAIN, {
light.DOMAIN: {
'platform': 'mqtt_json',
'name': 'test',
@@ -93,7 +93,7 @@ class TestLightMQTTJSON(unittest.TestCase):
# pylint: disable=invalid-name
"""Test the controlling of the state via topic."""
self.hass.config.components = ['mqtt']
assert _setup_component(self.hass, light.DOMAIN, {
assert setup_component(self.hass, light.DOMAIN, {
light.DOMAIN: {
'platform': 'mqtt_json',
'name': 'test',
@@ -153,7 +153,7 @@ class TestLightMQTTJSON(unittest.TestCase):
# pylint: disable=invalid-name
"""Test the sending of command in optimistic mode."""
self.hass.config.components = ['mqtt']
assert _setup_component(self.hass, light.DOMAIN, {
assert setup_component(self.hass, light.DOMAIN, {
light.DOMAIN: {
'platform': 'mqtt_json',
'name': 'test',
@@ -209,7 +209,7 @@ class TestLightMQTTJSON(unittest.TestCase):
# pylint: disable=invalid-name
"""Test for flash length being sent when included."""
self.hass.config.components = ['mqtt']
assert _setup_component(self.hass, light.DOMAIN, {
assert setup_component(self.hass, light.DOMAIN, {
light.DOMAIN: {
'platform': 'mqtt_json',
'name': 'test',
@@ -251,7 +251,7 @@ class TestLightMQTTJSON(unittest.TestCase):
def test_transition(self):
"""Test for transition time being sent when included."""
self.hass.config.components = ['mqtt']
assert _setup_component(self.hass, light.DOMAIN, {
assert setup_component(self.hass, light.DOMAIN, {
light.DOMAIN: {
'platform': 'mqtt_json',
'name': 'test',
@@ -293,7 +293,7 @@ class TestLightMQTTJSON(unittest.TestCase):
# pylint: disable=invalid-name
"""Test that invalid color/brightness values are ignored."""
self.hass.config.components = ['mqtt']
assert _setup_component(self.hass, light.DOMAIN, {
assert setup_component(self.hass, light.DOMAIN, {
light.DOMAIN: {
'platform': 'mqtt_json',
'name': 'test',
+10 -10
View File
@@ -3,7 +3,7 @@ import unittest
import pytest
from homeassistant.bootstrap import _setup_component
from homeassistant.bootstrap import setup_component
from homeassistant.components import rfxtrx as rfxtrx_core
from tests.common import get_test_home_assistant
@@ -28,7 +28,7 @@ class TestLightRfxtrx(unittest.TestCase):
def test_valid_config(self):
"""Test configuration."""
self.assertTrue(_setup_component(self.hass, 'light', {
self.assertTrue(setup_component(self.hass, 'light', {
'light': {'platform': 'rfxtrx',
'automatic_add': True,
'devices':
@@ -36,7 +36,7 @@ class TestLightRfxtrx(unittest.TestCase):
'name': 'Test',
rfxtrx_core.ATTR_FIREEVENT: True}}}}))
self.assertTrue(_setup_component(self.hass, 'light', {
self.assertTrue(setup_component(self.hass, 'light', {
'light': {'platform': 'rfxtrx',
'automatic_add': True,
'devices':
@@ -47,7 +47,7 @@ class TestLightRfxtrx(unittest.TestCase):
def test_invalid_config(self):
"""Test configuration."""
self.assertFalse(_setup_component(self.hass, 'light', {
self.assertFalse(setup_component(self.hass, 'light', {
'light': {'platform': 'rfxtrx',
'automatic_add': True,
'invalid_key': 'afda',
@@ -59,14 +59,14 @@ class TestLightRfxtrx(unittest.TestCase):
def test_default_config(self):
"""Test with 0 switches."""
self.assertTrue(_setup_component(self.hass, 'light', {
self.assertTrue(setup_component(self.hass, 'light', {
'light': {'platform': 'rfxtrx',
'devices': {}}}))
self.assertEqual(0, len(rfxtrx_core.RFX_DEVICES))
def test_old_config(self):
"""Test with 1 light."""
self.assertTrue(_setup_component(self.hass, 'light', {
self.assertTrue(setup_component(self.hass, 'light', {
'light': {'platform': 'rfxtrx',
'devices':
{'123efab1': {
@@ -110,7 +110,7 @@ class TestLightRfxtrx(unittest.TestCase):
def test_one_light(self):
"""Test with 1 light."""
self.assertTrue(_setup_component(self.hass, 'light', {
self.assertTrue(setup_component(self.hass, 'light', {
'light': {'platform': 'rfxtrx',
'devices':
{'0b1100cd0213c7f210010f51': {
@@ -179,7 +179,7 @@ class TestLightRfxtrx(unittest.TestCase):
def test_several_lights(self):
"""Test with 3 lights."""
self.assertTrue(_setup_component(self.hass, 'light', {
self.assertTrue(setup_component(self.hass, 'light', {
'light': {'platform': 'rfxtrx',
'signal_repetitions': 3,
'devices':
@@ -212,7 +212,7 @@ class TestLightRfxtrx(unittest.TestCase):
def test_discover_light(self):
"""Test with discovery of lights."""
self.assertTrue(_setup_component(self.hass, 'light', {
self.assertTrue(setup_component(self.hass, 'light', {
'light': {'platform': 'rfxtrx',
'automatic_add': True,
'devices': {}}}))
@@ -265,7 +265,7 @@ class TestLightRfxtrx(unittest.TestCase):
def test_discover_light_noautoadd(self):
"""Test with discover of light when auto add is False."""
self.assertTrue(_setup_component(self.hass, 'light', {
self.assertTrue(setup_component(self.hass, 'light', {
'light': {'platform': 'rfxtrx',
'automatic_add': False,
'devices': {}}}))