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,7 +1,7 @@
|
||||
"""The tests for the MQTT switch platform."""
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import _setup_component
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.const import STATE_ON, STATE_OFF, ATTR_ASSUMED_STATE
|
||||
import homeassistant.components.switch as switch
|
||||
from tests.common import (
|
||||
@@ -23,7 +23,7 @@ class TestSensorMQTT(unittest.TestCase):
|
||||
def test_controlling_state_via_topic(self):
|
||||
"""Test the controlling state via topic."""
|
||||
self.hass.config.components = ['mqtt']
|
||||
assert _setup_component(self.hass, switch.DOMAIN, {
|
||||
assert setup_component(self.hass, switch.DOMAIN, {
|
||||
switch.DOMAIN: {
|
||||
'platform': 'mqtt',
|
||||
'name': 'test',
|
||||
@@ -53,7 +53,7 @@ class TestSensorMQTT(unittest.TestCase):
|
||||
def test_sending_mqtt_commands_and_optimistic(self):
|
||||
"""Test the sending MQTT commands in optimistic mode."""
|
||||
self.hass.config.components = ['mqtt']
|
||||
assert _setup_component(self.hass, switch.DOMAIN, {
|
||||
assert setup_component(self.hass, switch.DOMAIN, {
|
||||
switch.DOMAIN: {
|
||||
'platform': 'mqtt',
|
||||
'name': 'test',
|
||||
@@ -87,7 +87,7 @@ class TestSensorMQTT(unittest.TestCase):
|
||||
def test_controlling_state_via_topic_and_json_message(self):
|
||||
"""Test the controlling state via topic and JSON message."""
|
||||
self.hass.config.components = ['mqtt']
|
||||
assert _setup_component(self.hass, switch.DOMAIN, {
|
||||
assert setup_component(self.hass, switch.DOMAIN, {
|
||||
switch.DOMAIN: {
|
||||
'platform': 'mqtt',
|
||||
'name': 'test',
|
||||
|
||||
@@ -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 TestSwitchRfxtrx(unittest.TestCase):
|
||||
|
||||
def test_valid_config(self):
|
||||
"""Test configuration."""
|
||||
self.assertTrue(_setup_component(self.hass, 'switch', {
|
||||
self.assertTrue(setup_component(self.hass, 'switch', {
|
||||
'switch': {'platform': 'rfxtrx',
|
||||
'automatic_add': True,
|
||||
'devices':
|
||||
@@ -39,7 +39,7 @@ class TestSwitchRfxtrx(unittest.TestCase):
|
||||
|
||||
def test_valid_config_int_device_id(self):
|
||||
"""Test configuration."""
|
||||
self.assertTrue(_setup_component(self.hass, 'switch', {
|
||||
self.assertTrue(setup_component(self.hass, 'switch', {
|
||||
'switch': {'platform': 'rfxtrx',
|
||||
'automatic_add': True,
|
||||
'devices':
|
||||
@@ -49,7 +49,7 @@ class TestSwitchRfxtrx(unittest.TestCase):
|
||||
}}}))
|
||||
|
||||
def test_invalid_config1(self):
|
||||
self.assertFalse(_setup_component(self.hass, 'switch', {
|
||||
self.assertFalse(setup_component(self.hass, 'switch', {
|
||||
'switch': {'platform': 'rfxtrx',
|
||||
'automatic_add': True,
|
||||
'devices':
|
||||
@@ -61,7 +61,7 @@ class TestSwitchRfxtrx(unittest.TestCase):
|
||||
|
||||
def test_invalid_config2(self):
|
||||
"""Test configuration."""
|
||||
self.assertFalse(_setup_component(self.hass, 'switch', {
|
||||
self.assertFalse(setup_component(self.hass, 'switch', {
|
||||
'switch': {'platform': 'rfxtrx',
|
||||
'automatic_add': True,
|
||||
'invalid_key': 'afda',
|
||||
@@ -73,7 +73,7 @@ class TestSwitchRfxtrx(unittest.TestCase):
|
||||
}}}))
|
||||
|
||||
def test_invalid_config3(self):
|
||||
self.assertFalse(_setup_component(self.hass, 'switch', {
|
||||
self.assertFalse(setup_component(self.hass, 'switch', {
|
||||
'switch': {'platform': 'rfxtrx',
|
||||
'automatic_add': True,
|
||||
'devices':
|
||||
@@ -85,7 +85,7 @@ class TestSwitchRfxtrx(unittest.TestCase):
|
||||
|
||||
def test_invalid_config4(self):
|
||||
"""Test configuration."""
|
||||
self.assertFalse(_setup_component(self.hass, 'switch', {
|
||||
self.assertFalse(setup_component(self.hass, 'switch', {
|
||||
'switch': {'platform': 'rfxtrx',
|
||||
'automatic_add': True,
|
||||
'devices':
|
||||
@@ -96,7 +96,7 @@ class TestSwitchRfxtrx(unittest.TestCase):
|
||||
|
||||
def test_default_config(self):
|
||||
"""Test with 0 switches."""
|
||||
self.assertTrue(_setup_component(self.hass, 'switch', {
|
||||
self.assertTrue(setup_component(self.hass, 'switch', {
|
||||
'switch': {'platform': 'rfxtrx',
|
||||
'devices':
|
||||
{}}}))
|
||||
@@ -104,7 +104,7 @@ class TestSwitchRfxtrx(unittest.TestCase):
|
||||
|
||||
def test_old_config(self):
|
||||
"""Test with 1 switch."""
|
||||
self.assertTrue(_setup_component(self.hass, 'switch', {
|
||||
self.assertTrue(setup_component(self.hass, 'switch', {
|
||||
'switch': {'platform': 'rfxtrx',
|
||||
'devices':
|
||||
{'123efab1': {
|
||||
@@ -132,7 +132,7 @@ class TestSwitchRfxtrx(unittest.TestCase):
|
||||
|
||||
def test_one_switch(self):
|
||||
"""Test with 1 switch."""
|
||||
self.assertTrue(_setup_component(self.hass, 'switch', {
|
||||
self.assertTrue(setup_component(self.hass, 'switch', {
|
||||
'switch': {'platform': 'rfxtrx',
|
||||
'devices':
|
||||
{'0b1100cd0213c7f210010f51': {
|
||||
@@ -170,7 +170,7 @@ class TestSwitchRfxtrx(unittest.TestCase):
|
||||
|
||||
def test_several_switches(self):
|
||||
"""Test with 3 switches."""
|
||||
self.assertTrue(_setup_component(self.hass, 'switch', {
|
||||
self.assertTrue(setup_component(self.hass, 'switch', {
|
||||
'switch': {'platform': 'rfxtrx',
|
||||
'signal_repetitions': 3,
|
||||
'devices':
|
||||
@@ -203,7 +203,7 @@ class TestSwitchRfxtrx(unittest.TestCase):
|
||||
|
||||
def test_discover_switch(self):
|
||||
"""Test with discovery of switches."""
|
||||
self.assertTrue(_setup_component(self.hass, 'switch', {
|
||||
self.assertTrue(setup_component(self.hass, 'switch', {
|
||||
'switch': {'platform': 'rfxtrx',
|
||||
'automatic_add': True,
|
||||
'devices': {}}}))
|
||||
@@ -253,7 +253,7 @@ class TestSwitchRfxtrx(unittest.TestCase):
|
||||
|
||||
def test_discover_switch_noautoadd(self):
|
||||
"""Test with discovery of switch when auto add is False."""
|
||||
self.assertTrue(_setup_component(self.hass, 'switch', {
|
||||
self.assertTrue(setup_component(self.hass, 'switch', {
|
||||
'switch': {'platform': 'rfxtrx',
|
||||
'automatic_add': False,
|
||||
'devices': {}}}))
|
||||
|
||||
Reference in new issue
Block a user