Move more MQTT platforms to config entries (#16918)
* Move more MQTT platforms to config entries * Address comments
This commit is contained in:
1 parent
720b05c301
commit
af89e7c50f
15 files changed
+214
-101
No files matched your search
@@ -6,12 +6,12 @@ from homeassistant.const import (
|
||||
STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY,
|
||||
STATE_ALARM_PENDING, STATE_ALARM_TRIGGERED, STATE_UNAVAILABLE,
|
||||
STATE_UNKNOWN)
|
||||
from homeassistant.components import alarm_control_panel
|
||||
from homeassistant.components import alarm_control_panel, mqtt
|
||||
from homeassistant.components.mqtt.discovery import async_start
|
||||
|
||||
from tests.common import (
|
||||
mock_mqtt_component, async_fire_mqtt_message, fire_mqtt_message,
|
||||
get_test_home_assistant, assert_setup_component)
|
||||
get_test_home_assistant, assert_setup_component, MockConfigEntry)
|
||||
from tests.components.alarm_control_panel import common
|
||||
|
||||
CODE = 'HELLO_CODE'
|
||||
@@ -245,7 +245,8 @@ class TestAlarmControlPanelMQTT(unittest.TestCase):
|
||||
|
||||
async def test_discovery_removal_alarm(hass, mqtt_mock, caplog):
|
||||
"""Test removal of discovered alarm_control_panel."""
|
||||
await async_start(hass, 'homeassistant', {})
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
await async_start(hass, 'homeassistant', {}, entry)
|
||||
|
||||
data = (
|
||||
'{ "name": "Beer",'
|
||||
|
||||
@@ -3,7 +3,7 @@ import unittest
|
||||
|
||||
import homeassistant.core as ha
|
||||
from homeassistant.setup import setup_component, async_setup_component
|
||||
import homeassistant.components.binary_sensor as binary_sensor
|
||||
from homeassistant.components import binary_sensor, mqtt
|
||||
from homeassistant.components.mqtt.discovery import async_start
|
||||
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
@@ -11,7 +11,8 @@ from homeassistant.const import EVENT_STATE_CHANGED, STATE_UNAVAILABLE
|
||||
|
||||
from tests.common import (
|
||||
get_test_home_assistant, fire_mqtt_message, async_fire_mqtt_message,
|
||||
mock_component, mock_mqtt_component, async_mock_mqtt_component)
|
||||
mock_component, mock_mqtt_component, async_mock_mqtt_component,
|
||||
MockConfigEntry)
|
||||
|
||||
|
||||
class TestSensorMQTT(unittest.TestCase):
|
||||
@@ -231,7 +232,8 @@ async def test_unique_id(hass):
|
||||
|
||||
async def test_discovery_removal_binary_sensor(hass, mqtt_mock, caplog):
|
||||
"""Test removal of discovered binary_sensor."""
|
||||
await async_start(hass, 'homeassistant', {})
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
await async_start(hass, 'homeassistant', {}, entry)
|
||||
data = (
|
||||
'{ "name": "Beer",'
|
||||
' "status_topic": "test_topic" }'
|
||||
|
||||
@@ -6,7 +6,7 @@ from homeassistant.util.unit_system import (
|
||||
METRIC_SYSTEM
|
||||
)
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components import climate
|
||||
from homeassistant.components import climate, mqtt
|
||||
from homeassistant.const import STATE_OFF, STATE_UNAVAILABLE
|
||||
from homeassistant.components.climate import (
|
||||
SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE,
|
||||
@@ -15,7 +15,7 @@ from homeassistant.components.climate import (
|
||||
from homeassistant.components.mqtt.discovery import async_start
|
||||
from tests.common import (get_test_home_assistant, mock_mqtt_component,
|
||||
async_fire_mqtt_message, fire_mqtt_message,
|
||||
mock_component)
|
||||
mock_component, MockConfigEntry)
|
||||
from tests.components.climate import common
|
||||
|
||||
ENTITY_CLIMATE = 'climate.test'
|
||||
@@ -656,7 +656,8 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
|
||||
async def test_discovery_removal_climate(hass, mqtt_mock, caplog):
|
||||
"""Test removal of discovered climate."""
|
||||
await async_start(hass, 'homeassistant', {})
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
await async_start(hass, 'homeassistant', {}, entry)
|
||||
data = (
|
||||
'{ "name": "Beer" }'
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""The tests for the MQTT cover platform."""
|
||||
import unittest
|
||||
|
||||
import homeassistant.components.cover as cover
|
||||
from homeassistant.components import cover, mqtt
|
||||
from homeassistant.components.cover import (ATTR_POSITION, ATTR_TILT_POSITION)
|
||||
from homeassistant.components.cover.mqtt import MqttCover
|
||||
from homeassistant.components.mqtt.discovery import async_start
|
||||
@@ -15,7 +15,7 @@ from homeassistant.setup import setup_component
|
||||
|
||||
from tests.common import (
|
||||
get_test_home_assistant, mock_mqtt_component, async_fire_mqtt_message,
|
||||
fire_mqtt_message)
|
||||
fire_mqtt_message, MockConfigEntry)
|
||||
|
||||
|
||||
class TestCoverMQTT(unittest.TestCase):
|
||||
@@ -761,7 +761,8 @@ class TestCoverMQTT(unittest.TestCase):
|
||||
|
||||
async def test_discovery_removal_cover(hass, mqtt_mock, caplog):
|
||||
"""Test removal of discovered cover."""
|
||||
await async_start(hass, 'homeassistant', {})
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
await async_start(hass, 'homeassistant', {}, entry)
|
||||
data = (
|
||||
'{ "name": "Beer",'
|
||||
' "command_topic": "test_topic" }'
|
||||
|
||||
@@ -145,13 +145,13 @@ from unittest.mock import patch
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.const import (
|
||||
STATE_ON, STATE_OFF, STATE_UNAVAILABLE, ATTR_ASSUMED_STATE)
|
||||
import homeassistant.components.light as light
|
||||
from homeassistant.components import light, mqtt
|
||||
from homeassistant.components.mqtt.discovery import async_start
|
||||
import homeassistant.core as ha
|
||||
|
||||
from tests.common import (
|
||||
assert_setup_component, get_test_home_assistant, mock_mqtt_component,
|
||||
async_fire_mqtt_message, fire_mqtt_message, mock_coro)
|
||||
async_fire_mqtt_message, fire_mqtt_message, mock_coro, MockConfigEntry)
|
||||
from tests.components.light import common
|
||||
|
||||
|
||||
@@ -883,7 +883,8 @@ class TestLightMQTT(unittest.TestCase):
|
||||
|
||||
async def test_discovery_removal_light(hass, mqtt_mock, caplog):
|
||||
"""Test removal of discovered light."""
|
||||
await async_start(hass, 'homeassistant', {})
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
await async_start(hass, 'homeassistant', {}, entry)
|
||||
|
||||
data = (
|
||||
'{ "name": "Beer",'
|
||||
|
||||
@@ -6,12 +6,12 @@ from homeassistant.setup import setup_component, async_setup_component
|
||||
from homeassistant.const import STATE_ON, STATE_OFF, STATE_UNAVAILABLE,\
|
||||
ATTR_ASSUMED_STATE
|
||||
import homeassistant.core as ha
|
||||
import homeassistant.components.switch as switch
|
||||
from homeassistant.components import switch, mqtt
|
||||
from homeassistant.components.mqtt.discovery import async_start
|
||||
|
||||
from tests.common import (
|
||||
mock_mqtt_component, fire_mqtt_message, get_test_home_assistant, mock_coro,
|
||||
async_mock_mqtt_component, async_fire_mqtt_message)
|
||||
async_mock_mqtt_component, async_fire_mqtt_message, MockConfigEntry)
|
||||
from tests.components.switch import common
|
||||
|
||||
|
||||
@@ -313,7 +313,8 @@ async def test_unique_id(hass):
|
||||
|
||||
async def test_discovery_removal_switch(hass, mqtt_mock, caplog):
|
||||
"""Test expansion of discovered switch."""
|
||||
await async_start(hass, 'homeassistant', {})
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
await async_start(hass, 'homeassistant', {}, entry)
|
||||
|
||||
data = (
|
||||
'{ "name": "Beer",'
|
||||
|
||||
Reference in new issue
Block a user