diff --git a/tests/common.py b/tests/common.py index 1c8a2454c12..18f827961d0 100644 --- a/tests/common.py +++ b/tests/common.py @@ -129,7 +129,6 @@ def mock_mqtt_component(hass, mock_mqtt): mqtt.CONF_BROKER: 'mock-broker', } }) - hass.config.components.append(mqtt.DOMAIN) return mock_mqtt diff --git a/tests/components/mqtt/test_init.py b/tests/components/mqtt/test_init.py index f342284cdec..9c168b71a32 100644 --- a/tests/components/mqtt/test_init.py +++ b/tests/components/mqtt/test_init.py @@ -49,6 +49,7 @@ class TestMQTT(unittest.TestCase): """Test for setup failure if connection to broker is missing.""" with mock.patch('homeassistant.components.mqtt.MQTT', side_effect=socket.error()): + self.hass.config.components = [] assert not _setup_component(self.hass, mqtt.DOMAIN, { mqtt.DOMAIN: { mqtt.CONF_BROKER: 'test-broker', @@ -214,12 +215,12 @@ class TestMQTTCallbacks(unittest.TestCase): # mock_mqtt_component(self.hass) 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.CONF_BROKER: 'mock-broker', } }) - self.hass.config.components.append(mqtt.DOMAIN) def tearDown(self): # pylint: disable=invalid-name """Stop everything that was started.""" diff --git a/tests/components/mqtt/test_server.py b/tests/components/mqtt/test_server.py index 1d0cd5d062e..ab84c3c29f0 100644 --- a/tests/components/mqtt/test_server.py +++ b/tests/components/mqtt/test_server.py @@ -33,13 +33,9 @@ class TestMQTT: assert mock_mqtt.mock_calls[0][1][5] == 'homeassistant' assert mock_mqtt.mock_calls[0][1][6] == password - @patch('homeassistant.components.mqtt.MQTT') - @patch('asyncio.gather') - @patch('asyncio.new_event_loop') - 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') + mock_mqtt.reset_mock() + + self.hass.config.components = ['http'] self.hass.config.api = MagicMock(api_password=None) assert _setup_component(self.hass, mqtt.DOMAIN, {}) assert mock_mqtt.called