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