mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Apply MQTT fixture types on platform tests (#87722)
* Apply MQTT fixture types on platform tests * Add caplog type hint * Add hass_ws_client type hint * Add tmp_path type hint * Add hass_client_no_auth type hint
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""The tests for the mqtt climate component."""
|
||||
import copy
|
||||
import json
|
||||
from pathlib import Path
|
||||
from unittest.mock import call, patch
|
||||
|
||||
import pytest
|
||||
@@ -63,6 +64,7 @@ from .test_common import (
|
||||
|
||||
from tests.common import async_fire_mqtt_message
|
||||
from tests.components.climate import common
|
||||
from tests.typing import MqttMockHAClientGenerator
|
||||
|
||||
ENTITY_CLIMATE = "climate.test"
|
||||
|
||||
@@ -102,7 +104,7 @@ def climate_platform_only():
|
||||
|
||||
|
||||
async def test_setup_params(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test the initial parameters."""
|
||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
||||
@@ -143,7 +145,7 @@ async def test_preset_none_in_preset_modes(hass: HomeAssistant, caplog) -> None:
|
||||
],
|
||||
)
|
||||
async def test_preset_modes_deprecation_guard(
|
||||
hass: HomeAssistant, caplog, parameter, config_value
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, parameter, config_value
|
||||
) -> None:
|
||||
"""Test the configuration for invalid legacy parameters."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][climate.DOMAIN])
|
||||
@@ -155,7 +157,7 @@ async def test_preset_modes_deprecation_guard(
|
||||
|
||||
|
||||
async def test_supported_features(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test the supported_features."""
|
||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
||||
@@ -177,7 +179,7 @@ async def test_supported_features(
|
||||
|
||||
|
||||
async def test_get_hvac_modes(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test that the operation list returns the correct modes."""
|
||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
||||
@@ -197,7 +199,9 @@ async def test_get_hvac_modes(
|
||||
|
||||
|
||||
async def test_set_operation_bad_attr_and_state(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test setting operation mode without required attribute.
|
||||
|
||||
@@ -220,7 +224,7 @@ async def test_set_operation_bad_attr_and_state(
|
||||
|
||||
|
||||
async def test_set_operation(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting of new operation mode."""
|
||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
||||
@@ -237,7 +241,7 @@ async def test_set_operation(
|
||||
|
||||
|
||||
async def test_set_operation_pessimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting operation mode in pessimistic mode."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -263,7 +267,7 @@ async def test_set_operation_pessimistic(
|
||||
|
||||
|
||||
async def test_set_operation_optimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting operation mode in optimistic mode."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -293,7 +297,7 @@ async def test_set_operation_optimistic(
|
||||
# support for CONF_POWER_STATE_TOPIC and CONF_POWER_STATE_TEMPLATE was already removed or never added
|
||||
# support was deprecated with release 2023.2 and will be removed with release 2023.8
|
||||
async def test_set_operation_with_power_command(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting of new operation mode with power command enabled."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -322,7 +326,9 @@ async def test_set_operation_with_power_command(
|
||||
|
||||
|
||||
async def test_set_fan_mode_bad_attr(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test setting fan mode without required attribute."""
|
||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
||||
@@ -341,7 +347,7 @@ async def test_set_fan_mode_bad_attr(
|
||||
|
||||
|
||||
async def test_set_fan_mode_pessimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting of new fan mode in pessimistic mode."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -367,7 +373,7 @@ async def test_set_fan_mode_pessimistic(
|
||||
|
||||
|
||||
async def test_set_fan_mode_optimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting of new fan mode in optimistic mode."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -394,7 +400,7 @@ async def test_set_fan_mode_optimistic(
|
||||
|
||||
|
||||
async def test_set_fan_mode(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting of new fan mode."""
|
||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
||||
@@ -410,7 +416,9 @@ async def test_set_fan_mode(
|
||||
|
||||
|
||||
async def test_set_swing_mode_bad_attr(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test setting swing mode without required attribute."""
|
||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
||||
@@ -429,7 +437,7 @@ async def test_set_swing_mode_bad_attr(
|
||||
|
||||
|
||||
async def test_set_swing_pessimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting swing mode in pessimistic mode."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -455,7 +463,7 @@ async def test_set_swing_pessimistic(
|
||||
|
||||
|
||||
async def test_set_swing_optimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting swing mode in optimistic mode."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -496,7 +504,7 @@ async def test_set_swing(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||
|
||||
|
||||
async def test_set_target_temperature(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting the target temperature."""
|
||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
||||
@@ -535,7 +543,7 @@ async def test_set_target_temperature(
|
||||
|
||||
|
||||
async def test_set_target_humidity(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting the target humidity."""
|
||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
||||
@@ -552,7 +560,7 @@ async def test_set_target_humidity(
|
||||
|
||||
|
||||
async def test_set_target_temperature_pessimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting the target temperature."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -578,7 +586,7 @@ async def test_set_target_temperature_pessimistic(
|
||||
|
||||
|
||||
async def test_set_target_temperature_optimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting the target temperature optimistic."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -605,7 +613,7 @@ async def test_set_target_temperature_optimistic(
|
||||
|
||||
|
||||
async def test_set_target_temperature_low_high(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting the low/high target temperature."""
|
||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
||||
@@ -623,7 +631,7 @@ async def test_set_target_temperature_low_high(
|
||||
|
||||
|
||||
async def test_set_target_temperature_low_highpessimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting the low/high target temperature."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -663,7 +671,7 @@ async def test_set_target_temperature_low_highpessimistic(
|
||||
|
||||
|
||||
async def test_set_target_temperature_low_high_optimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting the low/high target temperature optimistic."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -704,7 +712,7 @@ async def test_set_target_temperature_low_high_optimistic(
|
||||
|
||||
|
||||
async def test_set_target_humidity_optimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting the target humidity optimistic."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -730,7 +738,7 @@ async def test_set_target_humidity_optimistic(
|
||||
|
||||
|
||||
async def test_set_target_humidity_pessimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting the target humidity."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -755,7 +763,7 @@ async def test_set_target_humidity_pessimistic(
|
||||
|
||||
|
||||
async def test_receive_mqtt_temperature(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test getting the current temperature via MQTT."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -770,7 +778,7 @@ async def test_receive_mqtt_temperature(
|
||||
|
||||
|
||||
async def test_receive_mqtt_humidity(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test getting the current humidity via MQTT."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -785,7 +793,7 @@ async def test_receive_mqtt_humidity(
|
||||
|
||||
|
||||
async def test_handle_target_humidity_received(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting the target humidity via MQTT."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -804,7 +812,7 @@ async def test_handle_target_humidity_received(
|
||||
|
||||
|
||||
async def test_handle_action_received(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test getting the action received via MQTT."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -829,7 +837,9 @@ async def test_handle_action_received(
|
||||
|
||||
|
||||
async def test_set_preset_mode_optimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test setting of the preset mode."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -877,7 +887,9 @@ async def test_set_preset_mode_optimistic(
|
||||
|
||||
|
||||
async def test_set_preset_mode_explicit_optimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test setting of the preset mode."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -927,7 +939,9 @@ async def test_set_preset_mode_explicit_optimistic(
|
||||
|
||||
|
||||
async def test_set_preset_mode_pessimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test setting of the preset mode."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -974,7 +988,7 @@ async def test_set_preset_mode_pessimistic(
|
||||
|
||||
|
||||
async def test_set_aux_pessimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting of the aux heating in pessimistic mode."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -1024,7 +1038,7 @@ async def test_set_aux(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) ->
|
||||
|
||||
|
||||
async def test_availability_when_connection_lost(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test availability after MQTT disconnection."""
|
||||
await help_test_availability_when_connection_lost(
|
||||
@@ -1033,7 +1047,7 @@ async def test_availability_when_connection_lost(
|
||||
|
||||
|
||||
async def test_availability_without_topic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test availability without defined availability topic."""
|
||||
await help_test_availability_without_topic(
|
||||
@@ -1042,7 +1056,7 @@ async def test_availability_without_topic(
|
||||
|
||||
|
||||
async def test_default_availability_payload(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test availability by default payload with defined topic."""
|
||||
await help_test_default_availability_payload(
|
||||
@@ -1051,7 +1065,7 @@ async def test_default_availability_payload(
|
||||
|
||||
|
||||
async def test_custom_availability_payload(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test availability by custom payload with defined topic."""
|
||||
await help_test_custom_availability_payload(
|
||||
@@ -1060,7 +1074,9 @@ async def test_custom_availability_payload(
|
||||
|
||||
|
||||
async def test_get_target_temperature_low_high_with_templates(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test getting temperature high/low with templates."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -1098,7 +1114,9 @@ async def test_get_target_temperature_low_high_with_templates(
|
||||
|
||||
|
||||
async def test_get_with_templates(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test getting various attributes with templates."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -1217,7 +1235,9 @@ async def test_get_with_templates(
|
||||
|
||||
|
||||
async def test_set_and_templates(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test setting various attributes with templates."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -1307,7 +1327,7 @@ async def test_set_and_templates(
|
||||
|
||||
|
||||
async def test_min_temp_custom(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test a custom min temp."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -1325,7 +1345,7 @@ async def test_min_temp_custom(
|
||||
|
||||
|
||||
async def test_max_temp_custom(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test a custom max temp."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -1343,7 +1363,7 @@ async def test_max_temp_custom(
|
||||
|
||||
|
||||
async def test_min_humidity_custom(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test a custom min humidity."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -1361,7 +1381,7 @@ async def test_min_humidity_custom(
|
||||
|
||||
|
||||
async def test_max_humidity_custom(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test a custom max humidity."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -1379,7 +1399,7 @@ async def test_max_humidity_custom(
|
||||
|
||||
|
||||
async def test_temp_step_custom(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test a custom temp step."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -1397,7 +1417,7 @@ async def test_temp_step_custom(
|
||||
|
||||
|
||||
async def test_temperature_unit(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test that setting temperature unit converts temperature values."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -1415,7 +1435,7 @@ async def test_temperature_unit(
|
||||
|
||||
|
||||
async def test_setting_attribute_via_mqtt_json_message(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||
await help_test_setting_attribute_via_mqtt_json_message(
|
||||
@@ -1424,7 +1444,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||
|
||||
|
||||
async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||
@@ -1437,7 +1457,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||
|
||||
|
||||
async def test_setting_attribute_with_template(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||
await help_test_setting_attribute_with_template(
|
||||
@@ -1446,7 +1466,9 @@ async def test_setting_attribute_with_template(
|
||||
|
||||
|
||||
async def test_update_with_json_attrs_not_dict(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test attributes get extracted from a JSON result."""
|
||||
await help_test_update_with_json_attrs_not_dict(
|
||||
@@ -1459,7 +1481,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||
|
||||
|
||||
async def test_update_with_json_attrs_bad_json(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test attributes get extracted from a JSON result."""
|
||||
await help_test_update_with_json_attrs_bad_json(
|
||||
@@ -1472,7 +1496,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||
|
||||
|
||||
async def test_discovery_update_attr(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update of discovered MQTTAttributes."""
|
||||
await help_test_discovery_update_attr(
|
||||
@@ -1529,8 +1555,8 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||
)
|
||||
async def test_encoding_subscribable_topics(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config,
|
||||
caplog,
|
||||
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
topic,
|
||||
value,
|
||||
attribute,
|
||||
@@ -1552,7 +1578,9 @@ async def test_encoding_subscribable_topics(
|
||||
|
||||
|
||||
async def test_discovery_removal_climate(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test removal of discovered climate."""
|
||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][climate.DOMAIN])
|
||||
@@ -1562,7 +1590,9 @@ async def test_discovery_removal_climate(
|
||||
|
||||
|
||||
async def test_discovery_update_climate(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update of discovered climate."""
|
||||
config1 = {"name": "Beer"}
|
||||
@@ -1573,7 +1603,9 @@ async def test_discovery_update_climate(
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_climate(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update of discovered climate."""
|
||||
data1 = '{ "name": "Beer" }'
|
||||
@@ -1592,7 +1624,9 @@ async def test_discovery_update_unchanged_climate(
|
||||
|
||||
@pytest.mark.no_fail_on_log_exception
|
||||
async def test_discovery_broken(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test handling of bad discovery message."""
|
||||
data1 = '{ "name": "Beer", "power_command_topic": "test_topic#" }'
|
||||
@@ -1603,7 +1637,7 @@ async def test_discovery_broken(
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test MQTT climate device registry integration."""
|
||||
await help_test_entity_device_info_with_connection(
|
||||
@@ -1612,7 +1646,7 @@ async def test_entity_device_info_with_connection(
|
||||
|
||||
|
||||
async def test_entity_device_info_with_identifier(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test MQTT climate device registry integration."""
|
||||
await help_test_entity_device_info_with_identifier(
|
||||
@@ -1621,7 +1655,7 @@ async def test_entity_device_info_with_identifier(
|
||||
|
||||
|
||||
async def test_entity_device_info_update(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test device registry update."""
|
||||
await help_test_entity_device_info_update(
|
||||
@@ -1630,7 +1664,7 @@ async def test_entity_device_info_update(
|
||||
|
||||
|
||||
async def test_entity_device_info_remove(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test device registry remove."""
|
||||
await help_test_entity_device_info_remove(
|
||||
@@ -1639,7 +1673,7 @@ async def test_entity_device_info_remove(
|
||||
|
||||
|
||||
async def test_entity_id_update_subscriptions(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||
config = {
|
||||
@@ -1661,7 +1695,7 @@ async def test_entity_id_update_subscriptions(
|
||||
|
||||
|
||||
async def test_entity_id_update_discovery_update(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test MQTT discovery update when entity_id is updated."""
|
||||
await help_test_entity_id_update_discovery_update(
|
||||
@@ -1670,7 +1704,7 @@ async def test_entity_id_update_discovery_update(
|
||||
|
||||
|
||||
async def test_entity_debug_info_message(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test MQTT debug info."""
|
||||
config = {
|
||||
@@ -1695,7 +1729,7 @@ async def test_entity_debug_info_message(
|
||||
|
||||
|
||||
async def test_precision_default(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test that setting precision to tenths works as intended."""
|
||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
||||
@@ -1711,7 +1745,7 @@ async def test_precision_default(
|
||||
|
||||
|
||||
async def test_precision_halves(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test that setting precision to halves works as intended."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -1729,7 +1763,7 @@ async def test_precision_halves(
|
||||
|
||||
|
||||
async def test_precision_whole(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test that setting precision to whole works as intended."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||
@@ -1831,8 +1865,8 @@ async def test_precision_whole(
|
||||
)
|
||||
async def test_publishing_with_custom_encoding(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config,
|
||||
caplog,
|
||||
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
service,
|
||||
topic,
|
||||
parameters,
|
||||
@@ -1919,7 +1953,10 @@ async def test_humidity_configuration_validity(
|
||||
|
||||
|
||||
async def test_reloadable(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog, tmp_path
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
"""Test reloading the MQTT platform."""
|
||||
domain = climate.DOMAIN
|
||||
@@ -1937,7 +1974,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||
|
||||
|
||||
async def test_unload_entry(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, tmp_path
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
"""Test unloading the config entry."""
|
||||
domain = climate.DOMAIN
|
||||
|
||||
Reference in New Issue
Block a user