Bootstrap / Component setup async (#6264)
* Bootstrap / Entiy setup async * Cleanup add_job stuff / return task/future object * Address paulus comments / part 1 * fix install pip * Cleanup bootstrap / move config stuff to config.py * Make demo async * Further bootstrap improvement * Address Martin's comments * Fix initial tests * Fix final tests * Fix bug with prepare loader * Remove no longer needed things * Log error when invalid config * More cleanup * Cleanups platform events & fix lint * Use a non blocking add_entities callback for platform * Fix Autoamtion is setup befor entity is ready * Better automation fix * Address paulus comments * Typo * fix lint * rename functions * fix tests * fix test * change exceptions * fix spell
This commit is contained in:
parent
383b0914b3
commit
41f558b181
109 changed files with 764 additions and 848 deletions
|
@ -4,7 +4,8 @@ from unittest.mock import Mock, MagicMock, patch
|
|||
from homeassistant.bootstrap import setup_component
|
||||
import homeassistant.components.mqtt as mqtt
|
||||
|
||||
from tests.common import get_test_home_assistant, mock_coro
|
||||
from tests.common import (
|
||||
get_test_home_assistant, mock_coro, mock_http_component)
|
||||
|
||||
|
||||
class TestMQTT:
|
||||
|
@ -13,7 +14,7 @@ class TestMQTT:
|
|||
def setup_method(self, method):
|
||||
"""Setup things to be run when tests are started."""
|
||||
self.hass = get_test_home_assistant()
|
||||
self.hass.config.components.add('http')
|
||||
mock_http_component(self.hass, 'super_secret')
|
||||
|
||||
def teardown_method(self, method):
|
||||
"""Stop everything that was started."""
|
||||
|
@ -33,13 +34,21 @@ class TestMQTT:
|
|||
self.hass.config.api = MagicMock(api_password=password)
|
||||
assert setup_component(self.hass, mqtt.DOMAIN, {})
|
||||
assert mock_mqtt.called
|
||||
from pprint import pprint
|
||||
pprint(mock_mqtt.mock_calls)
|
||||
assert mock_mqtt.mock_calls[1][1][5] == 'homeassistant'
|
||||
assert mock_mqtt.mock_calls[1][1][6] == password
|
||||
|
||||
mock_mqtt.reset_mock()
|
||||
@patch('passlib.apps.custom_app_context', Mock(return_value=''))
|
||||
@patch('tempfile.NamedTemporaryFile', Mock(return_value=MagicMock()))
|
||||
@patch('hbmqtt.broker.Broker', Mock(return_value=MagicMock()))
|
||||
@patch('hbmqtt.broker.Broker.start', Mock(return_value=mock_coro()))
|
||||
@patch('homeassistant.components.mqtt.MQTT')
|
||||
def test_creating_config_with_http_no_pass(self, mock_mqtt):
|
||||
"""Test if the MQTT server gets started and subscribe/publish msg."""
|
||||
mock_mqtt().async_connect.return_value = mock_coro(True)
|
||||
self.hass.bus.listen_once = MagicMock()
|
||||
|
||||
self.hass.config.components = set(['http'])
|
||||
self.hass.config.api = MagicMock(api_password=None)
|
||||
assert setup_component(self.hass, mqtt.DOMAIN, {})
|
||||
assert mock_mqtt.called
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue