Don't send MQTT birth message in tests (#43917)

This commit is contained in:
Erik Montnemery 2020-12-04 04:39:49 +01:00 committed by GitHub
parent a5279cc279
commit 5e6f5fca90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -781,6 +781,18 @@ async def test_custom_birth_message(hass, mqtt_client_mock, mqtt_mock):
mqtt_client_mock.publish.assert_called_with("birth", "birth", 0, False) mqtt_client_mock.publish.assert_called_with("birth", "birth", 0, False)
@pytest.mark.parametrize(
"mqtt_config",
[
{
mqtt.CONF_BROKER: "mock-broker",
mqtt.CONF_BIRTH_MESSAGE: {
mqtt.ATTR_TOPIC: "homeassistant/status",
mqtt.ATTR_PAYLOAD: "online",
},
}
],
)
async def test_default_birth_message(hass, mqtt_client_mock, mqtt_mock): async def test_default_birth_message(hass, mqtt_client_mock, mqtt_mock):
"""Test sending birth message.""" """Test sending birth message."""
birth = asyncio.Event() birth = asyncio.Event()

View file

@ -400,7 +400,7 @@ def mqtt_client_mock(hass):
async def mqtt_mock(hass, mqtt_client_mock, mqtt_config): async def mqtt_mock(hass, mqtt_client_mock, mqtt_config):
"""Fixture to mock MQTT component.""" """Fixture to mock MQTT component."""
if mqtt_config is None: if mqtt_config is None:
mqtt_config = {mqtt.CONF_BROKER: "mock-broker"} mqtt_config = {mqtt.CONF_BROKER: "mock-broker", mqtt.CONF_BIRTH_MESSAGE: {}}
result = await async_setup_component(hass, mqtt.DOMAIN, {mqtt.DOMAIN: mqtt_config}) result = await async_setup_component(hass, mqtt.DOMAIN, {mqtt.DOMAIN: mqtt_config})
assert result assert result