Remove unused parameter for MQTT discovery (#36526)
* Remove unused parameter for MQTT discovery * Fix tests
This commit is contained in:
1 parent
823f27db5a
commit
35cd6b9abf
10 files changed
+74
-87
No files matched your search
@@ -37,9 +37,8 @@ async def test_subscribing_config_topic(hass, mqtt_mock):
|
||||
"""Test setting up discovery."""
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN, data={mqtt.CONF_BROKER: "test-broker"})
|
||||
|
||||
hass_config = {}
|
||||
discovery_topic = "homeassistant"
|
||||
await async_start(hass, discovery_topic, hass_config, entry)
|
||||
await async_start(hass, discovery_topic, entry)
|
||||
|
||||
assert mqtt_mock.async_subscribe.called
|
||||
call_args = mqtt_mock.async_subscribe.mock_calls[0][1]
|
||||
@@ -57,7 +56,7 @@ async def test_invalid_topic(hass, mqtt_mock):
|
||||
)
|
||||
|
||||
mock_dispatcher_send = AsyncMock(return_value=None)
|
||||
await async_start(hass, "homeassistant", {}, entry)
|
||||
await async_start(hass, "homeassistant", entry)
|
||||
|
||||
async_fire_mqtt_message(
|
||||
hass, "homeassistant/binary_sensor/bla/not_config", "{}"
|
||||
@@ -76,7 +75,7 @@ async def test_invalid_json(hass, mqtt_mock, caplog):
|
||||
)
|
||||
|
||||
mock_dispatcher_send = AsyncMock(return_value=None)
|
||||
await async_start(hass, "homeassistant", {}, entry)
|
||||
await async_start(hass, "homeassistant", entry)
|
||||
|
||||
async_fire_mqtt_message(
|
||||
hass, "homeassistant/binary_sensor/bla/config", "not json"
|
||||
@@ -96,7 +95,7 @@ async def test_only_valid_components(hass, mqtt_mock, caplog):
|
||||
invalid_component = "timer"
|
||||
|
||||
mock_dispatcher_send = AsyncMock(return_value=None)
|
||||
await async_start(hass, "homeassistant", {}, entry)
|
||||
await async_start(hass, "homeassistant", entry)
|
||||
|
||||
async_fire_mqtt_message(
|
||||
hass, f"homeassistant/{invalid_component}/bla/config", "{}"
|
||||
@@ -113,7 +112,7 @@ async def test_correct_config_discovery(hass, mqtt_mock, caplog):
|
||||
"""Test sending in correct JSON."""
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
|
||||
await async_start(hass, "homeassistant", {}, entry)
|
||||
await async_start(hass, "homeassistant", entry)
|
||||
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
@@ -133,7 +132,7 @@ async def test_discover_fan(hass, mqtt_mock, caplog):
|
||||
"""Test discovering an MQTT fan."""
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
|
||||
await async_start(hass, "homeassistant", {}, entry)
|
||||
await async_start(hass, "homeassistant", entry)
|
||||
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
@@ -153,7 +152,7 @@ async def test_discover_climate(hass, mqtt_mock, caplog):
|
||||
"""Test discovering an MQTT climate component."""
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
|
||||
await async_start(hass, "homeassistant", {}, entry)
|
||||
await async_start(hass, "homeassistant", entry)
|
||||
|
||||
data = (
|
||||
'{ "name": "ClimateTest",'
|
||||
@@ -175,7 +174,7 @@ async def test_discover_alarm_control_panel(hass, mqtt_mock, caplog):
|
||||
"""Test discovering an MQTT alarm control panel component."""
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
|
||||
await async_start(hass, "homeassistant", {}, entry)
|
||||
await async_start(hass, "homeassistant", entry)
|
||||
|
||||
data = (
|
||||
'{ "name": "AlarmControlPanelTest",'
|
||||
@@ -197,7 +196,7 @@ async def test_discovery_incl_nodeid(hass, mqtt_mock, caplog):
|
||||
"""Test sending in correct JSON with optional node_id included."""
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
|
||||
await async_start(hass, "homeassistant", {}, entry)
|
||||
await async_start(hass, "homeassistant", entry)
|
||||
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
@@ -217,7 +216,7 @@ async def test_non_duplicate_discovery(hass, mqtt_mock, caplog):
|
||||
"""Test for a non duplicate component."""
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
|
||||
await async_start(hass, "homeassistant", {}, entry)
|
||||
await async_start(hass, "homeassistant", entry)
|
||||
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
@@ -244,7 +243,7 @@ async def test_removal(hass, mqtt_mock, caplog):
|
||||
"""Test removal of component through empty discovery message."""
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
|
||||
await async_start(hass, "homeassistant", {}, entry)
|
||||
await async_start(hass, "homeassistant", entry)
|
||||
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
@@ -265,7 +264,7 @@ async def test_rediscover(hass, mqtt_mock, caplog):
|
||||
"""Test rediscover of removed component."""
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
|
||||
await async_start(hass, "homeassistant", {}, entry)
|
||||
await async_start(hass, "homeassistant", entry)
|
||||
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
@@ -295,7 +294,7 @@ async def test_duplicate_removal(hass, mqtt_mock, caplog):
|
||||
"""Test for a non duplicate component."""
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
|
||||
await async_start(hass, "homeassistant", {}, entry)
|
||||
await async_start(hass, "homeassistant", entry)
|
||||
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
@@ -317,7 +316,7 @@ async def test_cleanup_device(hass, device_reg, entity_reg, mqtt_mock):
|
||||
"""Test discvered device is cleaned up when removed from registry."""
|
||||
config_entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
config_entry.add_to_hass(hass)
|
||||
await async_start(hass, "homeassistant", {}, config_entry)
|
||||
await async_start(hass, "homeassistant", config_entry)
|
||||
|
||||
data = (
|
||||
'{ "device":{"identifiers":["0AFFD2"]},'
|
||||
@@ -360,7 +359,7 @@ async def test_discovery_expansion(hass, mqtt_mock, caplog):
|
||||
"""Test expansion of abbreviated discovery payload."""
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
|
||||
await async_start(hass, "homeassistant", {}, entry)
|
||||
await async_start(hass, "homeassistant", entry)
|
||||
|
||||
data = (
|
||||
'{ "~": "some/base/topic",'
|
||||
@@ -450,7 +449,7 @@ async def test_no_implicit_state_topic_switch(hass, mqtt_mock, caplog):
|
||||
"""Test no implicit state topic for switch."""
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
|
||||
await async_start(hass, "homeassistant", {}, entry)
|
||||
await async_start(hass, "homeassistant", entry)
|
||||
|
||||
data = '{ "name": "Test1",' ' "command_topic": "cmnd"' "}"
|
||||
|
||||
@@ -475,7 +474,7 @@ async def test_complex_discovery_topic_prefix(hass, mqtt_mock, caplog):
|
||||
"""Tests handling of discovery topic prefix with multiple slashes."""
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN)
|
||||
|
||||
await async_start(hass, "my_home/homeassistant/register", {}, entry)
|
||||
await async_start(hass, "my_home/homeassistant/register", entry)
|
||||
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
|
||||
Reference in new issue
Block a user