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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 290 additions and 289 deletions

View file

@ -1010,31 +1010,33 @@ async def test_supported_features(
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == features
@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, humidifier.DOMAIN, DEFAULT_CONFIG
hass, mqtt_mock_entry_no_yaml_config, humidifier.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, humidifier.DOMAIN, DEFAULT_CONFIG
hass, mqtt_mock_entry_no_yaml_config, humidifier.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."""
await help_test_default_availability_payload(
hass,
mqtt_mock_entry_with_yaml_config,
mqtt_mock_entry_no_yaml_config,
humidifier.DOMAIN,
DEFAULT_CONFIG,
True,
@ -1044,12 +1046,12 @@ 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."""
await help_test_custom_availability_payload(
hass,
mqtt_mock_entry_with_yaml_config,
mqtt_mock_entry_no_yaml_config,
humidifier.DOMAIN,
DEFAULT_CONFIG,
True,