1
0
mirror of https://github.com/home-assistant/core synced 2024-07-01 07:15:04 +00:00

Cleanup mqtt platform tests part 5 (#120719)

This commit is contained in:
Jan Bouwhuis 2024-06-28 16:22:56 +02:00 committed by GitHub
parent a8f4684929
commit e907c45981
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 36 additions and 79 deletions

View File

@ -1236,8 +1236,7 @@ async def test_publishing_with_custom_encoding(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = alarm_control_panel.DOMAIN
@ -1260,8 +1259,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = alarm_control_panel.DOMAIN

View File

@ -1025,8 +1025,7 @@ async def test_entity_debug_info_message(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = binary_sensor.DOMAIN

View File

@ -480,8 +480,7 @@ async def test_publishing_with_custom_encoding(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = button.DOMAIN
@ -504,8 +503,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = button.DOMAIN

View File

@ -389,8 +389,7 @@ async def test_entity_debug_info_message(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = camera.DOMAIN
@ -413,8 +412,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = camera.DOMAIN

View File

@ -3461,8 +3461,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = cover.DOMAIN

View File

@ -91,8 +91,7 @@ DEFAULT_CONFIG = {
],
)
async def test_run_lawn_mower_setup_and_state_updates(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test that it sets up correctly fetches the given payload."""
await mqtt_mock_entry()
@ -503,8 +502,7 @@ async def test_discovery_removal_lawn_mower(
async def test_discovery_update_lawn_mower(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test update of discovered lawn_mower."""
config1 = {
@ -763,8 +761,7 @@ async def test_publishing_with_custom_encoding(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = lawn_mower.DOMAIN
@ -818,8 +815,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = lawn_mower.DOMAIN

View File

@ -2559,9 +2559,7 @@ async def test_discovery_removal_light(
async def test_discovery_ignores_extra_keys(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test discovery ignores extra keys that are not blocked."""
await mqtt_mock_entry()
@ -3287,8 +3285,7 @@ async def test_publishing_with_custom_encoding(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = light.DOMAIN
@ -3370,7 +3367,6 @@ async def test_encoding_subscribable_topics(
async def test_encoding_subscribable_topics_brightness(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
topic: str,
value: str,
attribute: str,
@ -3582,8 +3578,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = light.DOMAIN

View File

@ -185,7 +185,6 @@ class JsonValidator:
"hass_config", [{mqtt.DOMAIN: {light.DOMAIN: {"schema": "json", "name": "test"}}}]
)
async def test_fail_setup_if_no_command_topic(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
) -> None:
@ -204,7 +203,6 @@ async def test_fail_setup_if_no_command_topic(
],
)
async def test_fail_setup_if_color_mode_deprecated(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
) -> None:
@ -233,7 +231,6 @@ async def test_fail_setup_if_color_mode_deprecated(
ids=["color_temp", "hs", "rgb", "xy", "color_temp, rgb"],
)
async def test_warning_if_color_mode_flags_are_used(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
color_modes: tuple[str, ...],
@ -316,7 +313,6 @@ async def test_warning_on_discovery_if_color_mode_flags_are_used(
ids=["color_temp"],
)
async def test_warning_if_color_mode_option_flag_is_used(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
) -> None:
@ -393,7 +389,6 @@ async def test_warning_on_discovery_if_color_mode_option_flag_is_used(
],
)
async def test_fail_setup_if_color_modes_invalid(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
error: str,
@ -421,8 +416,7 @@ async def test_fail_setup_if_color_modes_invalid(
],
)
async def test_single_color_mode(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test setup with single color_mode."""
await mqtt_mock_entry()
@ -448,8 +442,7 @@ async def test_single_color_mode(
@pytest.mark.parametrize("hass_config", [COLOR_MODES_CONFIG])
async def test_turn_on_with_unknown_color_mode_optimistic(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test setup and turn with unknown color_mode in optimistic mode."""
await mqtt_mock_entry()
@ -486,8 +479,7 @@ async def test_turn_on_with_unknown_color_mode_optimistic(
],
)
async def test_controlling_state_with_unknown_color_mode(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test setup and turn with unknown color_mode in optimistic mode."""
await mqtt_mock_entry()
@ -2658,8 +2650,7 @@ async def test_publishing_with_custom_encoding(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = light.DOMAIN

View File

@ -1280,8 +1280,7 @@ async def test_publishing_with_custom_encoding(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = light.DOMAIN
@ -1335,8 +1334,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = light.DOMAIN

View File

@ -996,8 +996,7 @@ async def test_publishing_with_custom_encoding(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = lock.DOMAIN
@ -1047,8 +1046,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = lock.DOMAIN

View File

@ -15,7 +15,7 @@ from homeassistant.core import CoreState, HomeAssistant, callback
from homeassistant.helpers import device_registry as dr, issue_registry as ir
from tests.common import MockConfigEntry, async_capture_events, async_fire_mqtt_message
from tests.typing import MqttMockHAClientGenerator, MqttMockPahoClient
from tests.typing import MqttMockHAClientGenerator
@pytest.mark.parametrize(
@ -37,8 +37,7 @@ from tests.typing import MqttMockHAClientGenerator, MqttMockPahoClient
],
)
async def test_availability_with_shared_state_topic(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test the state is not changed twice.
@ -295,11 +294,10 @@ async def test_availability_with_shared_state_topic(
],
)
@patch("homeassistant.components.mqtt.client.DISCOVERY_COOLDOWN", 0.0)
@pytest.mark.usefixtures("mqtt_client_mock")
async def test_default_entity_and_device_name(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
mqtt_client_mock: MqttMockPahoClient,
mqtt_config_entry_data,
caplog: pytest.LogCaptureFixture,
entity_id: str,
friendly_name: str,
@ -341,8 +339,7 @@ async def test_default_entity_and_device_name(
async def test_name_attribute_is_set_or_not(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test frendly name with device_class set.

View File

@ -427,8 +427,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = notify.DOMAIN

View File

@ -783,7 +783,6 @@ async def test_min_max_step_attributes(
],
)
async def test_invalid_min_max_attributes(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
) -> None:
@ -863,7 +862,7 @@ async def test_default_mode(
async def test_mode(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
mode,
mode: str,
) -> None:
"""Test mode."""
await mqtt_mock_entry()
@ -1022,8 +1021,7 @@ async def test_publishing_with_custom_encoding(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = number.DOMAIN
@ -1074,8 +1072,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = number.DOMAIN

View File

@ -382,8 +382,7 @@ async def test_publishing_with_custom_encoding(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = scene.DOMAIN
@ -406,8 +405,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = scene.DOMAIN

View File

@ -615,9 +615,7 @@ def _test_options_attributes_options_config(
_test_options_attributes_options_config((["milk", "beer"], ["milk"], [])),
)
async def test_options_attributes(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
options: list[str],
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, options: list[str]
) -> None:
"""Test options attribute."""
await mqtt_mock_entry()
@ -701,8 +699,7 @@ async def test_publishing_with_custom_encoding(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = select.DOMAIN
@ -755,8 +752,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = select.DOMAIN