mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Fixes for mqtt config validation tests.
This commit is contained in:
parent
8cca2bb344
commit
58ea589f99
@ -129,7 +129,6 @@ def mock_mqtt_component(hass, mock_mqtt):
|
|||||||
mqtt.CONF_BROKER: 'mock-broker',
|
mqtt.CONF_BROKER: 'mock-broker',
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
hass.config.components.append(mqtt.DOMAIN)
|
|
||||||
return mock_mqtt
|
return mock_mqtt
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ class TestMQTT(unittest.TestCase):
|
|||||||
"""Test for setup failure if connection to broker is missing."""
|
"""Test for setup failure if connection to broker is missing."""
|
||||||
with mock.patch('homeassistant.components.mqtt.MQTT',
|
with mock.patch('homeassistant.components.mqtt.MQTT',
|
||||||
side_effect=socket.error()):
|
side_effect=socket.error()):
|
||||||
|
self.hass.config.components = []
|
||||||
assert not _setup_component(self.hass, mqtt.DOMAIN, {
|
assert not _setup_component(self.hass, mqtt.DOMAIN, {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
mqtt.CONF_BROKER: 'test-broker',
|
mqtt.CONF_BROKER: 'test-broker',
|
||||||
@ -214,12 +215,12 @@ class TestMQTTCallbacks(unittest.TestCase):
|
|||||||
# mock_mqtt_component(self.hass)
|
# mock_mqtt_component(self.hass)
|
||||||
|
|
||||||
with mock.patch('paho.mqtt.client.Client'):
|
with mock.patch('paho.mqtt.client.Client'):
|
||||||
_setup_component(self.hass, mqtt.DOMAIN, {
|
self.hass.config.components = []
|
||||||
|
assert _setup_component(self.hass, mqtt.DOMAIN, {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
mqtt.CONF_BROKER: 'mock-broker',
|
mqtt.CONF_BROKER: 'mock-broker',
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
self.hass.config.components.append(mqtt.DOMAIN)
|
|
||||||
|
|
||||||
def tearDown(self): # pylint: disable=invalid-name
|
def tearDown(self): # pylint: disable=invalid-name
|
||||||
"""Stop everything that was started."""
|
"""Stop everything that was started."""
|
||||||
|
@ -33,13 +33,9 @@ class TestMQTT:
|
|||||||
assert mock_mqtt.mock_calls[0][1][5] == 'homeassistant'
|
assert mock_mqtt.mock_calls[0][1][5] == 'homeassistant'
|
||||||
assert mock_mqtt.mock_calls[0][1][6] == password
|
assert mock_mqtt.mock_calls[0][1][6] == password
|
||||||
|
|
||||||
@patch('homeassistant.components.mqtt.MQTT')
|
mock_mqtt.reset_mock()
|
||||||
@patch('asyncio.gather')
|
|
||||||
@patch('asyncio.new_event_loop')
|
self.hass.config.components = ['http']
|
||||||
def test_creating_config_no_http_pass(self, mock_new_loop, mock_gather,
|
|
||||||
mock_mqtt):
|
|
||||||
"""Test if the MQTT server gets started and subscribe/publish msg."""
|
|
||||||
self.hass.config.components.append('http')
|
|
||||||
self.hass.config.api = MagicMock(api_password=None)
|
self.hass.config.api = MagicMock(api_password=None)
|
||||||
assert _setup_component(self.hass, mqtt.DOMAIN, {})
|
assert _setup_component(self.hass, mqtt.DOMAIN, {})
|
||||||
assert mock_mqtt.called
|
assert mock_mqtt.called
|
||||||
|
Loading…
x
Reference in New Issue
Block a user