mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Cleanup common mqtt tests (#120446)
This commit is contained in:
parent
185e79fa1b
commit
cbcf29720d
@ -192,7 +192,7 @@ def does_not_raise():
|
||||
],
|
||||
)
|
||||
async def test_fail_setup_without_state_or_command_topic(
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, valid
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, valid: bool
|
||||
) -> None:
|
||||
"""Test for failing setup with no state or command topic."""
|
||||
assert await mqtt_mock_entry()
|
||||
@ -351,8 +351,8 @@ async def test_supported_features(
|
||||
async def test_publish_mqtt_no_code(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
service,
|
||||
payload,
|
||||
service: str,
|
||||
payload: str,
|
||||
) -> None:
|
||||
"""Test publishing of MQTT messages when no code is configured."""
|
||||
mqtt_mock = await mqtt_mock_entry()
|
||||
@ -952,17 +952,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,
|
||||
alarm_control_panel.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, alarm_control_panel.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -997,21 +991,17 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_alarm(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered alarm_control_panel."""
|
||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][alarm_control_panel.DOMAIN])
|
||||
await help_test_discovery_removal(
|
||||
hass, mqtt_mock_entry, caplog, alarm_control_panel.DOMAIN, data
|
||||
hass, mqtt_mock_entry, alarm_control_panel.DOMAIN, data
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_alarm_topic_and_template(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered alarm_control_panel."""
|
||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][alarm_control_panel.DOMAIN])
|
||||
@ -1036,7 +1026,6 @@ async def test_discovery_update_alarm_topic_and_template(
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
alarm_control_panel.DOMAIN,
|
||||
config1,
|
||||
config2,
|
||||
@ -1046,9 +1035,7 @@ async def test_discovery_update_alarm_topic_and_template(
|
||||
|
||||
|
||||
async def test_discovery_update_alarm_template(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered alarm_control_panel."""
|
||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][alarm_control_panel.DOMAIN])
|
||||
@ -1071,7 +1058,6 @@ async def test_discovery_update_alarm_template(
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
alarm_control_panel.DOMAIN,
|
||||
config1,
|
||||
config2,
|
||||
@ -1081,9 +1067,7 @@ async def test_discovery_update_alarm_template(
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_alarm(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered alarm_control_panel."""
|
||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][alarm_control_panel.DOMAIN])
|
||||
@ -1096,7 +1080,6 @@ async def test_discovery_update_unchanged_alarm(
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
alarm_control_panel.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
@ -1105,9 +1088,7 @@ async def test_discovery_update_unchanged_alarm(
|
||||
|
||||
@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" }'
|
||||
@ -1117,12 +1098,7 @@ async def test_discovery_broken(
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
await help_test_discovery_broken(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
alarm_control_panel.DOMAIN,
|
||||
data1,
|
||||
data2,
|
||||
hass, mqtt_mock_entry, alarm_control_panel.DOMAIN, data1, data2
|
||||
)
|
||||
|
||||
|
||||
|
@ -90,7 +90,6 @@ DEFAULT_CONFIG = {
|
||||
async def test_setting_sensor_value_expires_availability_topic(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test the expiration of the value."""
|
||||
await mqtt_mock_entry()
|
||||
@ -797,17 +796,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,
|
||||
binary_sensor.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, binary_sensor.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -840,21 +833,15 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_binary_sensor(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered binary_sensor."""
|
||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][binary_sensor.DOMAIN])
|
||||
await help_test_discovery_removal(
|
||||
hass, mqtt_mock_entry, caplog, binary_sensor.DOMAIN, data
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, binary_sensor.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_binary_sensor_topic_template(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered binary_sensor."""
|
||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][binary_sensor.DOMAIN])
|
||||
@ -881,7 +868,6 @@ async def test_discovery_update_binary_sensor_topic_template(
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
binary_sensor.DOMAIN,
|
||||
config1,
|
||||
config2,
|
||||
@ -891,9 +877,7 @@ async def test_discovery_update_binary_sensor_topic_template(
|
||||
|
||||
|
||||
async def test_discovery_update_binary_sensor_template(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered binary_sensor."""
|
||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][binary_sensor.DOMAIN])
|
||||
@ -918,7 +902,6 @@ async def test_discovery_update_binary_sensor_template(
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
binary_sensor.DOMAIN,
|
||||
config1,
|
||||
config2,
|
||||
@ -962,9 +945,7 @@ async def test_encoding_subscribable_topics(
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_binary_sensor(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered binary_sensor."""
|
||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][binary_sensor.DOMAIN])
|
||||
@ -975,31 +956,19 @@ async def test_discovery_update_unchanged_binary_sensor(
|
||||
"homeassistant.components.mqtt.binary_sensor.MqttBinarySensor.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
binary_sensor.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, binary_sensor.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", "off_delay": -1 }'
|
||||
data2 = '{ "name": "Milk", "state_topic": "test_topic" }'
|
||||
await help_test_discovery_broken(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
binary_sensor.DOMAIN,
|
||||
data1,
|
||||
data2,
|
||||
hass, mqtt_mock_entry, binary_sensor.DOMAIN, data1, data2
|
||||
)
|
||||
|
||||
|
||||
|
@ -252,17 +252,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,
|
||||
button.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, button.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -295,21 +289,15 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_button(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered button."""
|
||||
data = '{ "name": "test", "command_topic": "test_topic" }'
|
||||
await help_test_discovery_removal(
|
||||
hass, mqtt_mock_entry, caplog, button.DOMAIN, data
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, button.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_button(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered button."""
|
||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][button.DOMAIN])
|
||||
@ -318,19 +306,12 @@ async def test_discovery_update_button(
|
||||
config2["name"] = "Milk"
|
||||
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
button.DOMAIN,
|
||||
config1,
|
||||
config2,
|
||||
hass, mqtt_mock_entry, button.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_button(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered button."""
|
||||
data1 = (
|
||||
@ -342,27 +323,18 @@ async def test_discovery_update_unchanged_button(
|
||||
"homeassistant.components.mqtt.button.MqttButton.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
button.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, button.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" }'
|
||||
data2 = '{ "name": "Milk", "command_topic": "test_topic" }'
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, button.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, button.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
@ -246,17 +246,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,
|
||||
camera.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, camera.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -289,35 +283,28 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_camera(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered camera."""
|
||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][camera.DOMAIN])
|
||||
await help_test_discovery_removal(
|
||||
hass, mqtt_mock_entry, caplog, camera.DOMAIN, data
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, camera.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_camera(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update of discovered camera."""
|
||||
config1 = {"name": "Beer", "topic": "test_topic"}
|
||||
config2 = {"name": "Milk", "topic": "test_topic"}
|
||||
|
||||
await help_test_discovery_update(
|
||||
hass, mqtt_mock_entry, caplog, camera.DOMAIN, config1, config2
|
||||
hass, mqtt_mock_entry, camera.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_camera(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered camera."""
|
||||
data1 = '{ "name": "Beer", "topic": "test_topic"}'
|
||||
@ -325,28 +312,19 @@ async def test_discovery_update_unchanged_camera(
|
||||
"homeassistant.components.mqtt.camera.MqttCamera.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
camera.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, camera.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" }'
|
||||
data2 = '{ "name": "Milk", "topic": "test_topic"}'
|
||||
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, camera.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, camera.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
@ -1903,17 +1903,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,
|
||||
climate.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, climate.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -1987,34 +1981,26 @@ async def test_encoding_subscribable_topics(
|
||||
|
||||
|
||||
async def test_discovery_removal_climate(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered climate."""
|
||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][climate.DOMAIN])
|
||||
await help_test_discovery_removal(
|
||||
hass, mqtt_mock_entry, caplog, climate.DOMAIN, data
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, climate.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_climate(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered climate."""
|
||||
config1 = {"name": "Beer"}
|
||||
config2 = {"name": "Milk"}
|
||||
await help_test_discovery_update(
|
||||
hass, mqtt_mock_entry, caplog, climate.DOMAIN, config1, config2
|
||||
hass, mqtt_mock_entry, climate.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_climate(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered climate."""
|
||||
data1 = '{ "name": "Beer" }'
|
||||
@ -2022,26 +2008,19 @@ async def test_discovery_update_unchanged_climate(
|
||||
"homeassistant.components.mqtt.climate.MqttClimate.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
climate.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, climate.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", "power_command_topic": "test_topic#" }'
|
||||
data2 = '{ "name": "Milk", "power_command_topic": "test_topic" }'
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, climate.DOMAIN, data1, data2
|
||||
hass, mqtt_mock_entry, climate.DOMAIN, data1, data2
|
||||
)
|
||||
|
||||
|
||||
|
@ -103,9 +103,7 @@ def help_custom_config(
|
||||
|
||||
|
||||
async def help_test_availability_when_connection_lost(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
domain: str,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, domain: str
|
||||
) -> None:
|
||||
"""Test availability after MQTT disconnection."""
|
||||
mqtt_mock = await mqtt_mock_entry()
|
||||
@ -251,8 +249,6 @@ async def help_test_default_availability_list_payload_all(
|
||||
domain: str,
|
||||
config: ConfigType,
|
||||
no_assumed_state: bool = False,
|
||||
state_topic: str | None = None,
|
||||
state_message: str | None = None,
|
||||
) -> None:
|
||||
"""Test availability by default payload with defined topic.
|
||||
|
||||
@ -314,8 +310,6 @@ async def help_test_default_availability_list_payload_any(
|
||||
domain: str,
|
||||
config: ConfigType,
|
||||
no_assumed_state: bool = False,
|
||||
state_topic: str | None = None,
|
||||
state_message: str | None = None,
|
||||
) -> None:
|
||||
"""Test availability by default payload with defined topic.
|
||||
|
||||
@ -657,7 +651,6 @@ async def help_test_update_with_json_attrs_bad_json(
|
||||
async def help_test_discovery_update_attr(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
domain: str,
|
||||
config: ConfigType,
|
||||
) -> None:
|
||||
@ -696,9 +689,7 @@ async def help_test_discovery_update_attr(
|
||||
|
||||
|
||||
async def help_test_unique_id(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
domain: str,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, domain: str
|
||||
) -> None:
|
||||
"""Test unique id option only creates one entity per unique_id."""
|
||||
await mqtt_mock_entry()
|
||||
@ -709,7 +700,6 @@ async def help_test_unique_id(
|
||||
async def help_test_discovery_removal(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
domain: str,
|
||||
data: str,
|
||||
) -> None:
|
||||
@ -735,8 +725,7 @@ async def help_test_discovery_removal(
|
||||
async def help_test_discovery_update(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog,
|
||||
domain,
|
||||
domain: str,
|
||||
discovery_config1: DiscoveryInfoType,
|
||||
discovery_config2: DiscoveryInfoType,
|
||||
state_data1: _StateDataType | None = None,
|
||||
@ -800,7 +789,6 @@ async def help_test_discovery_update(
|
||||
async def help_test_discovery_update_unchanged(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
domain: str,
|
||||
data1: str,
|
||||
discovery_update: MagicMock,
|
||||
@ -826,7 +814,6 @@ async def help_test_discovery_update_unchanged(
|
||||
async def help_test_discovery_broken(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
domain: str,
|
||||
data1: str,
|
||||
data2: str,
|
||||
|
@ -2571,17 +2571,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,
|
||||
cover.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, cover.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -2614,32 +2608,26 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_cover(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered cover."""
|
||||
data = '{ "name": "test", "command_topic": "test_topic" }'
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, caplog, cover.DOMAIN, data)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, cover.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_cover(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered cover."""
|
||||
config1 = {"name": "Beer", "command_topic": "test_topic"}
|
||||
config2 = {"name": "Milk", "command_topic": "test_topic"}
|
||||
await help_test_discovery_update(
|
||||
hass, mqtt_mock_entry, caplog, cover.DOMAIN, config1, config2
|
||||
hass, mqtt_mock_entry, cover.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_cover(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered cover."""
|
||||
data1 = '{ "name": "Beer", "command_topic": "test_topic" }'
|
||||
@ -2647,27 +2635,18 @@ async def test_discovery_update_unchanged_cover(
|
||||
"homeassistant.components.mqtt.cover.MqttCover.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
cover.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, cover.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", "command_topic": "test_topic#" }'
|
||||
data2 = '{ "name": "Milk", "command_topic": "test_topic" }'
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, cover.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, cover.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
@ -397,17 +397,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,
|
||||
event.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, event.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -442,13 +436,11 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_event(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered event."""
|
||||
data = '{ "name": "test", "state_topic": "test_topic", "event_types": ["press"] }'
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, caplog, event.DOMAIN, data)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, event.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_event_template(
|
||||
@ -491,16 +483,12 @@ async def test_discovery_update_event_template(
|
||||
|
||||
@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", "state_topic": "test_topic#", "event_types": ["press"] }'
|
||||
data2 = '{ "name": "Milk", "state_topic": "test_topic", "event_types": ["press"] }'
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, event.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, event.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
@ -1989,13 +1989,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, fan.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry, fan.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -2030,32 +2028,26 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_fan(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered fan."""
|
||||
data = '{ "name": "test", "command_topic": "test_topic" }'
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, caplog, fan.DOMAIN, data)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, fan.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_fan(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered fan."""
|
||||
config1 = {"name": "Beer", "command_topic": "test_topic"}
|
||||
config2 = {"name": "Milk", "command_topic": "test_topic"}
|
||||
await help_test_discovery_update(
|
||||
hass, mqtt_mock_entry, caplog, fan.DOMAIN, config1, config2
|
||||
hass, mqtt_mock_entry, fan.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_fan(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered fan."""
|
||||
data1 = '{ "name": "Beer", "command_topic": "test_topic" }'
|
||||
@ -2063,28 +2055,19 @@ async def test_discovery_update_unchanged_fan(
|
||||
"homeassistant.components.mqtt.fan.MqttFan.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
fan.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, fan.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" }'
|
||||
data2 = '{ "name": "Milk", "command_topic": "test_topic" }'
|
||||
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, fan.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, fan.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
@ -1276,17 +1276,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,
|
||||
humidifier.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, humidifier.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -1323,21 +1317,15 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_humidifier(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered humidifier."""
|
||||
data = '{ "name": "test", "command_topic": "test_topic", "target_humidity_command_topic": "test-topic2" }'
|
||||
await help_test_discovery_removal(
|
||||
hass, mqtt_mock_entry, caplog, humidifier.DOMAIN, data
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, humidifier.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_humidifier(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered humidifier."""
|
||||
config1 = {
|
||||
@ -1351,19 +1339,12 @@ async def test_discovery_update_humidifier(
|
||||
"target_humidity_command_topic": "test-topic2",
|
||||
}
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
humidifier.DOMAIN,
|
||||
config1,
|
||||
config2,
|
||||
hass, mqtt_mock_entry, humidifier.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_humidifier(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered humidifier."""
|
||||
data1 = '{ "name": "Beer", "command_topic": "test_topic", "target_humidity_command_topic": "test-topic2" }'
|
||||
@ -1371,26 +1352,19 @@ async def test_discovery_update_unchanged_humidifier(
|
||||
"homeassistant.components.mqtt.fan.MqttFan.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
humidifier.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, humidifier.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" }'
|
||||
data2 = '{ "name": "Milk", "command_topic": "test_topic", "target_humidity_command_topic": "test-topic2" }'
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, humidifier.DOMAIN, data1, data2
|
||||
hass, mqtt_mock_entry, humidifier.DOMAIN, data1, data2
|
||||
)
|
||||
|
||||
|
||||
|
@ -600,17 +600,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,
|
||||
image.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, image.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -643,33 +637,27 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_image(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered image."""
|
||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][image.DOMAIN])
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, caplog, image.DOMAIN, data)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, image.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_image(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered image."""
|
||||
config1 = {"name": "Beer", "image_topic": "test_topic"}
|
||||
config2 = {"name": "Milk", "image_topic": "test_topic"}
|
||||
|
||||
await help_test_discovery_update(
|
||||
hass, mqtt_mock_entry, caplog, image.DOMAIN, config1, config2
|
||||
hass, mqtt_mock_entry, image.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_image(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered image."""
|
||||
data1 = '{ "name": "Beer", "image_topic": "test_topic"}'
|
||||
@ -677,28 +665,19 @@ async def test_discovery_update_unchanged_image(
|
||||
"homeassistant.components.mqtt.image.MqttImage.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
image.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, image.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" }'
|
||||
data2 = '{ "name": "Milk", "image_topic": "test_topic"}'
|
||||
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, image.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, image.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
@ -466,17 +466,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,
|
||||
lawn_mower.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, lawn_mower.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -509,21 +503,16 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_lawn_mower(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered lawn_mower."""
|
||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][lawn_mower.DOMAIN])
|
||||
await help_test_discovery_removal(
|
||||
hass, mqtt_mock_entry, caplog, lawn_mower.DOMAIN, data
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, lawn_mower.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_lawn_mower(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update of discovered lawn_mower."""
|
||||
config1 = {
|
||||
@ -540,14 +529,12 @@ async def test_discovery_update_lawn_mower(
|
||||
}
|
||||
|
||||
await help_test_discovery_update(
|
||||
hass, mqtt_mock_entry, caplog, lawn_mower.DOMAIN, config1, config2
|
||||
hass, mqtt_mock_entry, lawn_mower.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_lawn_mower(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered lawn_mower."""
|
||||
data1 = '{ "name": "Beer", "activity_state_topic": "test-topic", "command_topic": "test-topic", "actions": ["milk", "beer"]}'
|
||||
@ -555,27 +542,20 @@ async def test_discovery_update_unchanged_lawn_mower(
|
||||
"homeassistant.components.mqtt.lawn_mower.MqttLawnMower.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
lawn_mower.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, lawn_mower.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 = '{ "invalid" }'
|
||||
data2 = '{ "name": "Milk", "activity_state_topic": "test-topic", "pause_command_topic": "test-topic"}'
|
||||
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, lawn_mower.DOMAIN, data1, data2
|
||||
hass, mqtt_mock_entry, lawn_mower.DOMAIN, data1, data2
|
||||
)
|
||||
|
||||
|
||||
|
@ -2516,17 +2516,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
|
||||
)
|
||||
|
||||
|
||||
@ -2561,9 +2555,7 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_light(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered light."""
|
||||
data = (
|
||||
@ -2571,7 +2563,7 @@ async def test_discovery_removal_light(
|
||||
' "state_topic": "test_topic",'
|
||||
' "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_ignores_extra_keys(
|
||||
@ -2591,9 +2583,7 @@ async def test_discovery_ignores_extra_keys(
|
||||
|
||||
|
||||
async def test_discovery_update_light_topic_and_template(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered light."""
|
||||
config1 = {
|
||||
@ -2838,7 +2828,6 @@ async def test_discovery_update_light_topic_and_template(
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
config1,
|
||||
config2,
|
||||
@ -2848,9 +2837,7 @@ async def test_discovery_update_light_topic_and_template(
|
||||
|
||||
|
||||
async def test_discovery_update_light_template(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered light."""
|
||||
config1 = {
|
||||
@ -3053,7 +3040,6 @@ async def test_discovery_update_light_template(
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
config1,
|
||||
config2,
|
||||
@ -3063,9 +3049,7 @@ async def test_discovery_update_light_template(
|
||||
|
||||
|
||||
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 = (
|
||||
@ -3077,20 +3061,13 @@ async def test_discovery_update_unchanged_light(
|
||||
"homeassistant.components.mqtt.light.schema_basic.MqttLight.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" }'
|
||||
@ -3099,9 +3076,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(
|
||||
|
@ -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(
|
||||
|
@ -1002,17 +1002,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
|
||||
)
|
||||
|
||||
|
||||
@ -1053,9 +1047,7 @@ 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 = (
|
||||
@ -1065,13 +1057,11 @@ async def test_discovery_removal(
|
||||
' "command_on_template": "on",'
|
||||
' "command_off_template": "off"}'
|
||||
)
|
||||
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 = {
|
||||
@ -1091,14 +1081,12 @@ async def test_discovery_update_light(
|
||||
"command_off_template": "off",
|
||||
}
|
||||
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 = (
|
||||
@ -1113,20 +1101,13 @@ async def test_discovery_update_unchanged_light(
|
||||
"homeassistant.components.mqtt.light.schema_template.MqttLightTemplate.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" }'
|
||||
@ -1138,9 +1119,7 @@ async def test_discovery_broken(
|
||||
' "command_on_template": "on",'
|
||||
' "command_off_template": "off"}'
|
||||
)
|
||||
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(
|
||||
|
@ -805,13 +805,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, lock.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry, lock.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -846,19 +844,15 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_lock(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered lock."""
|
||||
data = '{ "name": "test", "command_topic": "test_topic" }'
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, caplog, lock.DOMAIN, data)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, lock.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_lock(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered lock."""
|
||||
config1 = {
|
||||
@ -874,14 +868,12 @@ async def test_discovery_update_lock(
|
||||
"availability_topic": "availability_topic2",
|
||||
}
|
||||
await help_test_discovery_update(
|
||||
hass, mqtt_mock_entry, caplog, lock.DOMAIN, config1, config2
|
||||
hass, mqtt_mock_entry, lock.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_lock(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered lock."""
|
||||
data1 = (
|
||||
@ -893,27 +885,18 @@ async def test_discovery_update_unchanged_lock(
|
||||
"homeassistant.components.mqtt.lock.MqttLock.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
lock.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, lock.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" }'
|
||||
data2 = '{ "name": "Milk", "command_topic": "test_topic" }'
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, lock.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, lock.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
@ -223,17 +223,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,
|
||||
notify.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, notify.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -266,21 +260,15 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_notify(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered notify."""
|
||||
data = '{ "name": "test", "command_topic": "test_topic" }'
|
||||
await help_test_discovery_removal(
|
||||
hass, mqtt_mock_entry, caplog, notify.DOMAIN, data
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, notify.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_notify(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered notify."""
|
||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][notify.DOMAIN])
|
||||
@ -289,19 +277,12 @@ async def test_discovery_update_notify(
|
||||
config2["name"] = "Milk"
|
||||
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
notify.DOMAIN,
|
||||
config1,
|
||||
config2,
|
||||
hass, mqtt_mock_entry, notify.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_notify(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered notify."""
|
||||
data1 = (
|
||||
@ -313,27 +294,18 @@ async def test_discovery_update_unchanged_notify(
|
||||
"homeassistant.components.mqtt.notify.MqttNotify.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
notify.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, notify.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" }'
|
||||
data2 = '{ "name": "Milk", "command_topic": "test_topic" }'
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, notify.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, notify.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
@ -581,17 +581,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,
|
||||
number.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, number.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -626,21 +620,15 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_number(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered number."""
|
||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][number.DOMAIN])
|
||||
await help_test_discovery_removal(
|
||||
hass, mqtt_mock_entry, caplog, number.DOMAIN, data
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, number.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_number(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered number."""
|
||||
config1 = {
|
||||
@ -655,14 +643,12 @@ async def test_discovery_update_number(
|
||||
}
|
||||
|
||||
await help_test_discovery_update(
|
||||
hass, mqtt_mock_entry, caplog, number.DOMAIN, config1, config2
|
||||
hass, mqtt_mock_entry, number.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_number(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered number."""
|
||||
data1 = (
|
||||
@ -672,20 +658,13 @@ async def test_discovery_update_unchanged_number(
|
||||
"homeassistant.components.mqtt.number.MqttNumber.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
number.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, number.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" }'
|
||||
@ -693,9 +672,7 @@ async def test_discovery_broken(
|
||||
'{ "name": "Milk", "state_topic": "test-topic", "command_topic": "test-topic"}'
|
||||
)
|
||||
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, number.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, number.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
@ -183,19 +183,15 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_scene(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered scene."""
|
||||
data = '{ "name": "test", "command_topic": "test_topic" }'
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, caplog, scene.DOMAIN, data)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, scene.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_payload(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered scene."""
|
||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][scene.DOMAIN])
|
||||
@ -206,19 +202,12 @@ async def test_discovery_update_payload(
|
||||
config2["payload_on"] = "ACTIVATE"
|
||||
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
scene.DOMAIN,
|
||||
config1,
|
||||
config2,
|
||||
hass, mqtt_mock_entry, scene.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_scene(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered scene."""
|
||||
data1 = '{ "name": "Beer", "command_topic": "test_topic" }'
|
||||
@ -226,27 +215,18 @@ async def test_discovery_update_unchanged_scene(
|
||||
"homeassistant.components.mqtt.scene.MqttScene.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
scene.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, scene.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" }'
|
||||
data2 = '{ "name": "Milk", "command_topic": "test_topic" }'
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, scene.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, scene.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_setting_attribute_via_mqtt_json_message(
|
||||
@ -307,17 +287,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,
|
||||
scene.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, scene.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
|
@ -431,17 +431,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,
|
||||
select.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, select.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -478,21 +472,15 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_select(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered select."""
|
||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][select.DOMAIN])
|
||||
await help_test_discovery_removal(
|
||||
hass, mqtt_mock_entry, caplog, select.DOMAIN, data
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, select.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_select(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered select."""
|
||||
config1 = {
|
||||
@ -509,14 +497,12 @@ async def test_discovery_update_select(
|
||||
}
|
||||
|
||||
await help_test_discovery_update(
|
||||
hass, mqtt_mock_entry, caplog, select.DOMAIN, config1, config2
|
||||
hass, mqtt_mock_entry, select.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_select(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered select."""
|
||||
data1 = '{ "name": "Beer", "state_topic": "test-topic", "command_topic": "test-topic", "options": ["milk", "beer"]}'
|
||||
@ -524,28 +510,19 @@ async def test_discovery_update_unchanged_select(
|
||||
"homeassistant.components.mqtt.select.MqttSelect.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
select.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, select.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" }'
|
||||
data2 = '{ "name": "Milk", "state_topic": "test-topic", "command_topic": "test-topic", "options": ["milk", "beer"]}'
|
||||
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, select.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, select.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
@ -978,15 +978,12 @@ 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,
|
||||
sensor.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
)
|
||||
@ -1021,21 +1018,15 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_sensor(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered sensor."""
|
||||
data = '{ "name": "test", "state_topic": "test_topic" }'
|
||||
await help_test_discovery_removal(
|
||||
hass, mqtt_mock_entry, caplog, sensor.DOMAIN, data
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, sensor.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_sensor_topic_template(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered sensor."""
|
||||
config = {"name": "test", "state_topic": "test_topic"}
|
||||
@ -1060,7 +1051,6 @@ async def test_discovery_update_sensor_topic_template(
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
sensor.DOMAIN,
|
||||
config1,
|
||||
config2,
|
||||
@ -1070,9 +1060,7 @@ async def test_discovery_update_sensor_topic_template(
|
||||
|
||||
|
||||
async def test_discovery_update_sensor_template(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered sensor."""
|
||||
config = {"name": "test", "state_topic": "test_topic"}
|
||||
@ -1095,7 +1083,6 @@ async def test_discovery_update_sensor_template(
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
sensor.DOMAIN,
|
||||
config1,
|
||||
config2,
|
||||
@ -1105,9 +1092,7 @@ async def test_discovery_update_sensor_template(
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_sensor(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered sensor."""
|
||||
data1 = '{ "name": "Beer", "state_topic": "test_topic" }'
|
||||
@ -1115,27 +1100,18 @@ async def test_discovery_update_unchanged_sensor(
|
||||
"homeassistant.components.mqtt.sensor.MqttSensor.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
sensor.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, sensor.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", "state_topic": "test_topic#" }'
|
||||
data2 = '{ "name": "Milk", "state_topic": "test_topic" }'
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, sensor.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, sensor.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
@ -642,17 +642,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,
|
||||
siren.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, siren.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -687,9 +681,7 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_siren(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered siren."""
|
||||
data = (
|
||||
@ -697,13 +689,11 @@ async def test_discovery_removal_siren(
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, caplog, siren.DOMAIN, data)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, siren.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_siren_topic_template(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered siren."""
|
||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][siren.DOMAIN])
|
||||
@ -730,7 +720,6 @@ async def test_discovery_update_siren_topic_template(
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
siren.DOMAIN,
|
||||
config1,
|
||||
config2,
|
||||
@ -740,9 +729,7 @@ async def test_discovery_update_siren_topic_template(
|
||||
|
||||
|
||||
async def test_discovery_update_siren_template(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered siren."""
|
||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][siren.DOMAIN])
|
||||
@ -767,7 +754,6 @@ async def test_discovery_update_siren_template(
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
siren.DOMAIN,
|
||||
config1,
|
||||
config2,
|
||||
@ -867,9 +853,7 @@ async def test_command_templates(
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_siren(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered siren."""
|
||||
data1 = (
|
||||
@ -884,7 +868,6 @@ async def test_discovery_update_unchanged_siren(
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
siren.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
@ -893,9 +876,7 @@ async def test_discovery_update_unchanged_siren(
|
||||
|
||||
@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" }'
|
||||
@ -904,9 +885,7 @@ async def test_discovery_broken(
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, siren.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, siren.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
@ -403,17 +403,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,
|
||||
switch.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, switch.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -448,9 +442,7 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_switch(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered switch."""
|
||||
data = (
|
||||
@ -458,15 +450,11 @@ async def test_discovery_removal_switch(
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
await help_test_discovery_removal(
|
||||
hass, mqtt_mock_entry, caplog, switch.DOMAIN, data
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, switch.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_switch_topic_template(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered switch."""
|
||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][switch.DOMAIN])
|
||||
@ -493,7 +481,6 @@ async def test_discovery_update_switch_topic_template(
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
switch.DOMAIN,
|
||||
config1,
|
||||
config2,
|
||||
@ -503,9 +490,7 @@ async def test_discovery_update_switch_topic_template(
|
||||
|
||||
|
||||
async def test_discovery_update_switch_template(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered switch."""
|
||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][switch.DOMAIN])
|
||||
@ -530,7 +515,6 @@ async def test_discovery_update_switch_template(
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
switch.DOMAIN,
|
||||
config1,
|
||||
config2,
|
||||
@ -542,7 +526,6 @@ async def test_discovery_update_switch_template(
|
||||
async def test_discovery_update_unchanged_switch(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update of discovered switch."""
|
||||
data1 = (
|
||||
@ -557,7 +540,6 @@ async def test_discovery_update_unchanged_switch(
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
switch.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
@ -566,9 +548,7 @@ async def test_discovery_update_unchanged_switch(
|
||||
|
||||
@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" }'
|
||||
@ -577,9 +557,7 @@ async def test_discovery_broken(
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, switch.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, switch.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
@ -529,17 +529,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,
|
||||
text.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, text.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -574,9 +568,7 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_text(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered text entity."""
|
||||
data = (
|
||||
@ -584,13 +576,11 @@ async def test_discovery_removal_text(
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, caplog, text.DOMAIN, data)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, text.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_text_update(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered text entity."""
|
||||
config1 = {
|
||||
@ -605,14 +595,12 @@ async def test_discovery_text_update(
|
||||
}
|
||||
|
||||
await help_test_discovery_update(
|
||||
hass, mqtt_mock_entry, caplog, text.DOMAIN, config1, config2
|
||||
hass, mqtt_mock_entry, text.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_update(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered update."""
|
||||
data1 = '{ "name": "Beer", "state_topic": "text-topic", "command_topic": "command-topic"}'
|
||||
@ -620,32 +608,23 @@ async def test_discovery_update_unchanged_update(
|
||||
"homeassistant.components.mqtt.text.MqttTextEntity.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
text.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, text.DOMAIN, data1, discovery_update
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_text(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered text entity."""
|
||||
config1 = {"name": "Beer", "command_topic": "cmd-topic1"}
|
||||
config2 = {"name": "Milk", "command_topic": "cmd-topic2"}
|
||||
await help_test_discovery_update(
|
||||
hass, mqtt_mock_entry, caplog, text.DOMAIN, config1, config2
|
||||
hass, mqtt_mock_entry, text.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_climate(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered text entity."""
|
||||
data1 = '{ "name": "Beer", "command_topic": "cmd-topic" }'
|
||||
@ -653,20 +632,13 @@ async def test_discovery_update_unchanged_climate(
|
||||
"homeassistant.components.mqtt.text.MqttTextEntity.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
text.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, text.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" }'
|
||||
@ -675,9 +647,7 @@ async def test_discovery_broken(
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, text.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, text.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
@ -530,15 +530,10 @@ async def test_update_with_json_attrs_bad_json(
|
||||
async def test_discovery_update_attr(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update of discovered MQTTAttributes."""
|
||||
await help_test_discovery_update_attr(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
update.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, update.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -573,21 +568,15 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_update(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered update."""
|
||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][update.DOMAIN])
|
||||
await help_test_discovery_removal(
|
||||
hass, mqtt_mock_entry, caplog, update.DOMAIN, data
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, update.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_update(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered update."""
|
||||
config1 = {
|
||||
@ -602,14 +591,12 @@ async def test_discovery_update_update(
|
||||
}
|
||||
|
||||
await help_test_discovery_update(
|
||||
hass, mqtt_mock_entry, caplog, update.DOMAIN, config1, config2
|
||||
hass, mqtt_mock_entry, update.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_update(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered update."""
|
||||
data1 = '{ "name": "Beer", "state_topic": "installed-topic", "latest_version_topic": "latest-topic"}'
|
||||
@ -617,28 +604,19 @@ async def test_discovery_update_unchanged_update(
|
||||
"homeassistant.components.mqtt.update.MqttUpdate.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
update.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, update.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" }'
|
||||
data2 = '{ "name": "Milk", "state_topic": "installed-topic", "latest_version_topic": "latest-topic" }'
|
||||
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, update.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, update.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
@ -531,17 +531,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,
|
||||
vacuum.DOMAIN,
|
||||
DEFAULT_CONFIG_2,
|
||||
hass, mqtt_mock_entry, vacuum.DOMAIN, DEFAULT_CONFIG_2
|
||||
)
|
||||
|
||||
|
||||
@ -574,34 +568,27 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_vacuum(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered vacuum."""
|
||||
data = '{"name": "test", "command_topic": "test_topic"}'
|
||||
await help_test_discovery_removal(
|
||||
hass, mqtt_mock_entry, caplog, vacuum.DOMAIN, data
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, vacuum.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_vacuum(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered vacuum."""
|
||||
config1 = {"name": "Beer", "command_topic": "test_topic"}
|
||||
config2 = {"name": "Milk", "command_topic": "test_topic"}
|
||||
await help_test_discovery_update(
|
||||
hass, mqtt_mock_entry, caplog, vacuum.DOMAIN, config1, config2
|
||||
hass, mqtt_mock_entry, vacuum.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_vacuum(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update of discovered vacuum."""
|
||||
data1 = '{"name": "Beer", "command_topic": "test_topic"}'
|
||||
@ -609,27 +596,18 @@ async def test_discovery_update_unchanged_vacuum(
|
||||
"homeassistant.components.mqtt.vacuum.MqttStateVacuum.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
vacuum.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, vacuum.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", "command_topic": "test_topic#"}'
|
||||
data2 = '{"name": "Milk", "command_topic": "test_topic"}'
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, vacuum.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, vacuum.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
@ -1200,15 +1200,10 @@ async def test_update_with_json_attrs_bad_json(
|
||||
async def test_discovery_update_attr(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update of discovered MQTTAttributes."""
|
||||
await help_test_discovery_update_attr(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
valve.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, valve.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -1241,32 +1236,26 @@ async def test_unique_id(
|
||||
|
||||
|
||||
async def test_discovery_removal_valve(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered valve."""
|
||||
data = '{ "name": "test", "command_topic": "test_topic" }'
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, caplog, valve.DOMAIN, data)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, valve.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_valve(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered valve."""
|
||||
config1 = {"name": "Beer", "command_topic": "test_topic"}
|
||||
config2 = {"name": "Milk", "command_topic": "test_topic"}
|
||||
await help_test_discovery_update(
|
||||
hass, mqtt_mock_entry, caplog, valve.DOMAIN, config1, config2
|
||||
hass, mqtt_mock_entry, valve.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_valve(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered valve."""
|
||||
data1 = '{ "name": "Beer", "command_topic": "test_topic" }'
|
||||
@ -1274,27 +1263,18 @@ async def test_discovery_update_unchanged_valve(
|
||||
"homeassistant.components.mqtt.valve.MqttValve.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
valve.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, valve.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", "command_topic": "test_topic#" }'
|
||||
data2 = '{ "name": "Milk", "command_topic": "test_topic" }'
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, valve.DOMAIN, data1, data2
|
||||
)
|
||||
await help_test_discovery_broken(hass, mqtt_mock_entry, valve.DOMAIN, data1, data2)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
|
@ -858,17 +858,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,
|
||||
water_heater.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
hass, mqtt_mock_entry, water_heater.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
@ -933,34 +927,26 @@ async def test_encoding_subscribable_topics(
|
||||
|
||||
|
||||
async def test_discovery_removal_water_heater(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test removal of discovered water heater."""
|
||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][water_heater.DOMAIN])
|
||||
await help_test_discovery_removal(
|
||||
hass, mqtt_mock_entry, caplog, water_heater.DOMAIN, data
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock_entry, water_heater.DOMAIN, data)
|
||||
|
||||
|
||||
async def test_discovery_update_water_heater(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered water heater."""
|
||||
config1 = {"name": "Beer"}
|
||||
config2 = {"name": "Milk"}
|
||||
await help_test_discovery_update(
|
||||
hass, mqtt_mock_entry, caplog, water_heater.DOMAIN, config1, config2
|
||||
hass, mqtt_mock_entry, water_heater.DOMAIN, config1, config2
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_water_heater(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test update of discovered water heater."""
|
||||
data1 = '{ "name": "Beer" }'
|
||||
@ -968,26 +954,19 @@ async def test_discovery_update_unchanged_water_heater(
|
||||
"homeassistant.components.mqtt.water_heater.MqttWaterHeater.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
water_heater.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
hass, mqtt_mock_entry, water_heater.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", "mode_command_topic": "test_topic#" }'
|
||||
data2 = '{ "name": "Milk", "mode_command_topic": "test_topic" }'
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock_entry, caplog, water_heater.DOMAIN, data1, data2
|
||||
hass, mqtt_mock_entry, water_heater.DOMAIN, data1, data2
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user