Add mqtt common tests for availability (part2) (#89805)

* update test_availability_when_connection_lost

* Adjust test_availability_without_topic

* Update test_default_availability_payload + helper

* Update test_default_availability_list_payload

* Use helper for async_setup_component

* Update test_default_availability_list_*

* Update test_custom_availability_payload
This commit is contained in:
Jan Bouwhuis
2023-03-21 08:20:37 +01:00
committed by GitHub
parent 0303618705
commit 91dbda1ce7
23 changed files with 290 additions and 289 deletions

View File

@ -457,26 +457,28 @@ async def test_filtering_not_supported_attributes_via_state(
assert state3.attributes.get(siren.ATTR_VOLUME_LEVEL) == 0.88
@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG])
async def test_availability_when_connection_lost(
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
) -> None:
"""Test availability after MQTT disconnection."""
await help_test_availability_when_connection_lost(
hass, mqtt_mock_entry_with_yaml_config, siren.DOMAIN, DEFAULT_CONFIG
hass, mqtt_mock_entry_no_yaml_config, siren.DOMAIN
)
@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG])
async def test_availability_without_topic(
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
) -> None:
"""Test availability without defined availability topic."""
await help_test_availability_without_topic(
hass, mqtt_mock_entry_with_yaml_config, siren.DOMAIN, DEFAULT_CONFIG
hass, mqtt_mock_entry_no_yaml_config, siren.DOMAIN, DEFAULT_CONFIG
)
async def test_default_availability_payload(
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
) -> None:
"""Test availability by default payload with defined topic."""
config = {
@ -490,10 +492,9 @@ async def test_default_availability_payload(
}
}
}
await help_test_default_availability_payload(
hass,
mqtt_mock_entry_with_yaml_config,
mqtt_mock_entry_no_yaml_config,
siren.DOMAIN,
config,
True,
@ -503,7 +504,7 @@ async def test_default_availability_payload(
async def test_custom_availability_payload(
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
) -> None:
"""Test availability by custom payload with defined topic."""
config = {
@ -520,7 +521,7 @@ async def test_custom_availability_payload(
await help_test_custom_availability_payload(
hass,
mqtt_mock_entry_with_yaml_config,
mqtt_mock_entry_no_yaml_config,
siren.DOMAIN,
config,
True,