Cleanup common mqtt tests (#120446)
This commit is contained in:
parent
185e79fa1b
commit
cbcf29720d
28 changed files with 266 additions and 904 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue