Test discovery subscriptions not done when discovery is disabled (#129458)
Test discovery subscriptions not performend when discovery is disabledpull/129502/head
parent
a6189106e1
commit
4e7397dc9d
|
@ -87,7 +87,8 @@ async def setup_with_birth_msg_client_mock(
|
||||||
patch("homeassistant.components.mqtt.client.SUBSCRIBE_COOLDOWN", 0.0),
|
patch("homeassistant.components.mqtt.client.SUBSCRIBE_COOLDOWN", 0.0),
|
||||||
):
|
):
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
domain=mqtt.DOMAIN, data={mqtt.CONF_BROKER: "test-broker"}
|
domain=mqtt.DOMAIN,
|
||||||
|
data=mqtt_config_entry_data or {mqtt.CONF_BROKER: "test-broker"},
|
||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
hass.config.components.add(mqtt.DOMAIN)
|
hass.config.components.add(mqtt.DOMAIN)
|
||||||
|
|
|
@ -1716,6 +1716,39 @@ async def test_mqtt_subscribes_topics_on_connect(
|
||||||
assert ("still/pending", 1) in subscribe_calls
|
assert ("still/pending", 1) in subscribe_calls
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"mqtt_config_entry_data",
|
||||||
|
[ENTRY_DEFAULT_BIRTH_MESSAGE | {mqtt.CONF_DISCOVERY: False}],
|
||||||
|
)
|
||||||
|
async def test_mqtt_discovery_not_subscribes_when_disabled(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_debouncer: asyncio.Event,
|
||||||
|
setup_with_birth_msg_client_mock: MqttMockPahoClient,
|
||||||
|
) -> None:
|
||||||
|
"""Test discovery subscriptions not performend when discovery is disabled."""
|
||||||
|
mqtt_client_mock = setup_with_birth_msg_client_mock
|
||||||
|
|
||||||
|
await mock_debouncer.wait()
|
||||||
|
|
||||||
|
subscribe_calls = help_all_subscribe_calls(mqtt_client_mock)
|
||||||
|
for component in SUPPORTED_COMPONENTS:
|
||||||
|
assert (f"homeassistant/{component}/+/config", 0) not in subscribe_calls
|
||||||
|
assert (f"homeassistant/{component}/+/+/config", 0) not in subscribe_calls
|
||||||
|
|
||||||
|
mqtt_client_mock.on_disconnect(Mock(), None, 0)
|
||||||
|
|
||||||
|
mqtt_client_mock.reset_mock()
|
||||||
|
|
||||||
|
mock_debouncer.clear()
|
||||||
|
mqtt_client_mock.on_connect(Mock(), None, 0, 0)
|
||||||
|
await mock_debouncer.wait()
|
||||||
|
|
||||||
|
subscribe_calls = help_all_subscribe_calls(mqtt_client_mock)
|
||||||
|
for component in SUPPORTED_COMPONENTS:
|
||||||
|
assert (f"homeassistant/{component}/+/config", 0) not in subscribe_calls
|
||||||
|
assert (f"homeassistant/{component}/+/+/config", 0) not in subscribe_calls
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"mqtt_config_entry_data",
|
"mqtt_config_entry_data",
|
||||||
[ENTRY_DEFAULT_BIRTH_MESSAGE],
|
[ENTRY_DEFAULT_BIRTH_MESSAGE],
|
||||||
|
|
Loading…
Reference in New Issue