mirror of
https://github.com/home-assistant/core.git
synced 2025-07-31 11:18:00 +02:00
Cleanup common mqtt tests (#120446)
This commit is contained in:
@@ -2398,17 +2398,11 @@ async def test_update_with_json_attrs_bad_json(
|
||||
|
||||
|
||||
async def test_discovery_update_attr(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered MQTTAttributes."""
|
||||
await help_test_discovery_update_attr(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@@ -2445,25 +2439,15 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered mqtt_json lights."""
|
||||
data = '{ "name": "test", "schema": "json", "command_topic": "test_topic" }'
|
||||
await help_test_discovery_removal(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
data,
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, light.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_light(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered light."""
|
||||
config1 = {
|
||||
@@ -2479,19 +2463,12 @@ async def test_discovery_update_light(
|
||||
"command_topic": "test_topic",
|
||||
}
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
config1,
|
||||
config2,
|
||||
hass, mqtt_mock_entry, light.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_light(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered light."""
|
||||
data1 = (
|
||||
@@ -2504,20 +2481,13 @@ async def test_discovery_update_unchanged_light(
|
||||
"homeassistant.components.mqtt.light.schema_json.MqttLightJson.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, light.DOMAIN, data1, discovery_update
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.no_fail_on_log_exception
|
||||
async def test_discovery_broken(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test handling of bad discovery message."""
|
||||
data1 = '{ "name": "Beer" }'
|
||||
@@ -2527,14 +2497,7 @@ async def test_discovery_broken(
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
await help_test_discovery_broken(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
data1,
|
||||
data2,
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, light.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
Reference in New Issue
Block a user