mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 20:25:07 +02:00
Add hass and None
return type on MQTT platform tests (#87713)
Add hass and `None` return type on MQTT tests
This commit is contained in:
@@ -193,7 +193,7 @@ from homeassistant.const import (
|
||||
STATE_UNKNOWN,
|
||||
Platform,
|
||||
)
|
||||
import homeassistant.core as ha
|
||||
from homeassistant.core import HomeAssistant, State
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .test_common import (
|
||||
@@ -241,7 +241,7 @@ def light_platform_only():
|
||||
yield
|
||||
|
||||
|
||||
async def test_fail_setup_if_no_command_topic(hass, caplog):
|
||||
async def test_fail_setup_if_no_command_topic(hass: HomeAssistant, caplog) -> None:
|
||||
"""Test if command fails with command topic."""
|
||||
assert not await async_setup_component(
|
||||
hass, mqtt.DOMAIN, {mqtt.DOMAIN: {light.DOMAIN: {"name": "test"}}}
|
||||
@@ -253,8 +253,8 @@ async def test_fail_setup_if_no_command_topic(hass, caplog):
|
||||
|
||||
|
||||
async def test_no_color_brightness_color_temp_hs_white_xy_if_no_topics(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test if there is no color and brightness if no topic."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
@@ -311,7 +311,9 @@ async def test_no_color_brightness_color_temp_hs_white_xy_if_no_topics(
|
||||
assert state.state == STATE_UNKNOWN
|
||||
|
||||
|
||||
async def test_controlling_state_via_topic(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_controlling_state_via_topic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test the controlling of the state via topic."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -430,7 +432,9 @@ async def test_controlling_state_via_topic(hass, mqtt_mock_entry_with_yaml_confi
|
||||
assert light_state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
||||
|
||||
|
||||
async def test_invalid_state_via_topic(hass, mqtt_mock_entry_with_yaml_config, caplog):
|
||||
async def test_invalid_state_via_topic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
||||
) -> None:
|
||||
"""Test handling of empty data via topic."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -554,7 +558,9 @@ async def test_invalid_state_via_topic(hass, mqtt_mock_entry_with_yaml_config, c
|
||||
assert light_state.attributes["color_temp"] == 153
|
||||
|
||||
|
||||
async def test_brightness_controlling_scale(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_brightness_controlling_scale(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test the brightness controlling scale."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
@@ -603,8 +609,8 @@ async def test_brightness_controlling_scale(hass, mqtt_mock_entry_with_yaml_conf
|
||||
|
||||
|
||||
async def test_brightness_from_rgb_controlling_scale(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test the brightness controlling scale."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
@@ -645,8 +651,8 @@ async def test_brightness_from_rgb_controlling_scale(
|
||||
|
||||
|
||||
async def test_controlling_state_via_topic_with_templates(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test the setting of the state with a template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -747,8 +753,8 @@ async def test_controlling_state_via_topic_with_templates(
|
||||
|
||||
|
||||
async def test_sending_mqtt_commands_and_optimistic(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test the sending of command in optimistic mode."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -769,7 +775,7 @@ async def test_sending_mqtt_commands_and_optimistic(
|
||||
}
|
||||
}
|
||||
color_modes = ["color_temp", "hs", "rgb", "rgbw", "rgbww", "xy"]
|
||||
fake_state = ha.State(
|
||||
fake_state = State(
|
||||
"light.test",
|
||||
"on",
|
||||
{
|
||||
@@ -936,8 +942,8 @@ async def test_sending_mqtt_commands_and_optimistic(
|
||||
|
||||
|
||||
async def test_sending_mqtt_rgb_command_with_template(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test the sending of RGB command with template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -975,8 +981,8 @@ async def test_sending_mqtt_rgb_command_with_template(
|
||||
|
||||
|
||||
async def test_sending_mqtt_rgbw_command_with_template(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test the sending of RGBW command with template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1014,8 +1020,8 @@ async def test_sending_mqtt_rgbw_command_with_template(
|
||||
|
||||
|
||||
async def test_sending_mqtt_rgbww_command_with_template(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test the sending of RGBWW command with template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1053,8 +1059,8 @@ async def test_sending_mqtt_rgbww_command_with_template(
|
||||
|
||||
|
||||
async def test_sending_mqtt_color_temp_command_with_template(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test the sending of Color Temp command with template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1090,7 +1096,9 @@ async def test_sending_mqtt_color_temp_command_with_template(
|
||||
assert state.attributes["color_temp"] == 100
|
||||
|
||||
|
||||
async def test_on_command_first(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_on_command_first(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test on command being sent before brightness."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1126,7 +1134,9 @@ async def test_on_command_first(hass, mqtt_mock_entry_with_yaml_config):
|
||||
mqtt_mock.async_publish.assert_called_once_with("test_light/set", "OFF", 0, False)
|
||||
|
||||
|
||||
async def test_on_command_last(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_on_command_last(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test on command being sent after brightness."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1161,7 +1171,9 @@ async def test_on_command_last(hass, mqtt_mock_entry_with_yaml_config):
|
||||
mqtt_mock.async_publish.assert_called_once_with("test_light/set", "OFF", 0, False)
|
||||
|
||||
|
||||
async def test_on_command_brightness(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_on_command_brightness(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test on command being sent as only brightness."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1216,7 +1228,9 @@ async def test_on_command_brightness(hass, mqtt_mock_entry_with_yaml_config):
|
||||
)
|
||||
|
||||
|
||||
async def test_on_command_brightness_scaled(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_on_command_brightness_scaled(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test brightness scale."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1286,7 +1300,9 @@ async def test_on_command_brightness_scaled(hass, mqtt_mock_entry_with_yaml_conf
|
||||
)
|
||||
|
||||
|
||||
async def test_on_command_rgb(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_on_command_rgb(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test on command in RGB brightness mode."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1376,7 +1392,9 @@ async def test_on_command_rgb(hass, mqtt_mock_entry_with_yaml_config):
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
|
||||
async def test_on_command_rgbw(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_on_command_rgbw(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test on command in RGBW brightness mode."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1466,7 +1484,9 @@ async def test_on_command_rgbw(hass, mqtt_mock_entry_with_yaml_config):
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
|
||||
async def test_on_command_rgbww(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_on_command_rgbww(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test on command in RGBWW brightness mode."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1556,7 +1576,9 @@ async def test_on_command_rgbww(hass, mqtt_mock_entry_with_yaml_config):
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
|
||||
async def test_on_command_rgb_template(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_on_command_rgb_template(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test on command in RGB brightness mode with RGB template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1593,7 +1615,9 @@ async def test_on_command_rgb_template(hass, mqtt_mock_entry_with_yaml_config):
|
||||
mqtt_mock.async_publish.assert_called_once_with("test_light/set", "OFF", 0, False)
|
||||
|
||||
|
||||
async def test_on_command_rgbw_template(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_on_command_rgbw_template(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test on command in RGBW brightness mode with RGBW template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1629,7 +1653,9 @@ async def test_on_command_rgbw_template(hass, mqtt_mock_entry_with_yaml_config):
|
||||
mqtt_mock.async_publish.assert_called_once_with("test_light/set", "OFF", 0, False)
|
||||
|
||||
|
||||
async def test_on_command_rgbww_template(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_on_command_rgbww_template(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test on command in RGBWW brightness mode with RGBWW template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1666,7 +1692,9 @@ async def test_on_command_rgbww_template(hass, mqtt_mock_entry_with_yaml_config)
|
||||
mqtt_mock.async_publish.assert_called_once_with("test_light/set", "OFF", 0, False)
|
||||
|
||||
|
||||
async def test_on_command_white(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_on_command_white(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test sending commands for RGB + white light."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1743,7 +1771,9 @@ async def test_on_command_white(hass, mqtt_mock_entry_with_yaml_config):
|
||||
)
|
||||
|
||||
|
||||
async def test_explicit_color_mode(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_explicit_color_mode(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test explicit color mode over mqtt."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1891,7 +1921,9 @@ async def test_explicit_color_mode(hass, mqtt_mock_entry_with_yaml_config):
|
||||
assert light_state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
||||
|
||||
|
||||
async def test_explicit_color_mode_templated(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_explicit_color_mode_templated(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test templated explicit color mode over mqtt."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1972,7 +2004,9 @@ async def test_explicit_color_mode_templated(hass, mqtt_mock_entry_with_yaml_con
|
||||
assert light_state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
||||
|
||||
|
||||
async def test_white_state_update(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_white_state_update(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test state updates for RGB + white light."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -2036,7 +2070,7 @@ async def test_white_state_update(hass, mqtt_mock_entry_with_yaml_config):
|
||||
assert state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
||||
|
||||
|
||||
async def test_effect(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_effect(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
||||
"""Test effect."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -2074,29 +2108,35 @@ async def test_effect(hass, mqtt_mock_entry_with_yaml_config):
|
||||
|
||||
|
||||
async def test_availability_when_connection_lost(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test availability after MQTT disconnection."""
|
||||
await help_test_availability_when_connection_lost(
|
||||
hass, mqtt_mock_entry_with_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_availability_without_topic(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_availability_without_topic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test availability without defined availability topic."""
|
||||
await help_test_availability_without_topic(
|
||||
hass, mqtt_mock_entry_with_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_default_availability_payload(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_default_availability_payload(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test availability by default payload with defined topic."""
|
||||
await help_test_default_availability_payload(
|
||||
hass, mqtt_mock_entry_with_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_custom_availability_payload(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_custom_availability_payload(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test availability by custom payload with defined topic."""
|
||||
await help_test_custom_availability_payload(
|
||||
hass, mqtt_mock_entry_with_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
@@ -2104,8 +2144,8 @@ async def test_custom_availability_payload(hass, mqtt_mock_entry_with_yaml_confi
|
||||
|
||||
|
||||
async def test_setting_attribute_via_mqtt_json_message(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||
await help_test_setting_attribute_via_mqtt_json_message(
|
||||
hass, mqtt_mock_entry_with_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
@@ -2113,8 +2153,8 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||
|
||||
|
||||
async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||
hass, mqtt_mock_entry_no_yaml_config
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
||||
) -> None:
|
||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||
hass,
|
||||
@@ -2125,7 +2165,9 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||
)
|
||||
|
||||
|
||||
async def test_setting_attribute_with_template(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_setting_attribute_with_template(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||
await help_test_setting_attribute_with_template(
|
||||
hass, mqtt_mock_entry_with_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
@@ -2133,8 +2175,8 @@ async def test_setting_attribute_with_template(hass, mqtt_mock_entry_with_yaml_c
|
||||
|
||||
|
||||
async def test_update_with_json_attrs_not_dict(
|
||||
hass, mqtt_mock_entry_with_yaml_config, caplog
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
||||
) -> None:
|
||||
"""Test attributes get extracted from a JSON result."""
|
||||
await help_test_update_with_json_attrs_not_dict(
|
||||
hass,
|
||||
@@ -2146,8 +2188,8 @@ async def test_update_with_json_attrs_not_dict(
|
||||
|
||||
|
||||
async def test_update_with_json_attrs_bad_json(
|
||||
hass, mqtt_mock_entry_with_yaml_config, caplog
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
||||
) -> None:
|
||||
"""Test attributes get extracted from a JSON result."""
|
||||
await help_test_update_with_json_attrs_bad_json(
|
||||
hass,
|
||||
@@ -2158,7 +2200,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_attr(hass, mqtt_mock_entry_no_yaml_config, caplog):
|
||||
async def test_discovery_update_attr(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
||||
) -> None:
|
||||
"""Test update of discovered MQTTAttributes."""
|
||||
await help_test_discovery_update_attr(
|
||||
hass,
|
||||
@@ -2169,7 +2213,7 @@ async def test_discovery_update_attr(hass, mqtt_mock_entry_no_yaml_config, caplo
|
||||
)
|
||||
|
||||
|
||||
async def test_unique_id(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
||||
"""Test unique id option only creates one light per unique_id."""
|
||||
config = {
|
||||
mqtt.DOMAIN: {
|
||||
@@ -2194,7 +2238,9 @@ async def test_unique_id(hass, mqtt_mock_entry_with_yaml_config):
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_removal_light(hass, mqtt_mock_entry_no_yaml_config, caplog):
|
||||
async def test_discovery_removal_light(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
||||
) -> None:
|
||||
"""Test removal of discovered light."""
|
||||
data = (
|
||||
'{ "name": "test",'
|
||||
@@ -2207,8 +2253,8 @@ async def test_discovery_removal_light(hass, mqtt_mock_entry_no_yaml_config, cap
|
||||
|
||||
|
||||
async def test_discovery_ignores_extra_keys(
|
||||
hass, mqtt_mock_entry_no_yaml_config, caplog
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
||||
) -> None:
|
||||
"""Test discovery ignores extra keys that are not blocked."""
|
||||
await mqtt_mock_entry_no_yaml_config()
|
||||
# inserted `platform` key should be ignored
|
||||
@@ -2223,8 +2269,8 @@ async def test_discovery_ignores_extra_keys(
|
||||
|
||||
|
||||
async def test_discovery_update_light_topic_and_template(
|
||||
hass, mqtt_mock_entry_no_yaml_config, caplog
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
||||
) -> None:
|
||||
"""Test update of discovered light."""
|
||||
config1 = {
|
||||
"name": "Beer",
|
||||
@@ -2478,8 +2524,8 @@ async def test_discovery_update_light_topic_and_template(
|
||||
|
||||
|
||||
async def test_discovery_update_light_template(
|
||||
hass, mqtt_mock_entry_no_yaml_config, caplog
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
||||
) -> None:
|
||||
"""Test update of discovered light."""
|
||||
config1 = {
|
||||
"name": "Beer",
|
||||
@@ -2691,8 +2737,8 @@ async def test_discovery_update_light_template(
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_light(
|
||||
hass, mqtt_mock_entry_no_yaml_config, caplog
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
||||
) -> None:
|
||||
"""Test update of discovered light."""
|
||||
data1 = (
|
||||
'{ "name": "Beer",'
|
||||
@@ -2713,7 +2759,9 @@ async def test_discovery_update_unchanged_light(
|
||||
|
||||
|
||||
@pytest.mark.no_fail_on_log_exception
|
||||
async def test_discovery_broken(hass, mqtt_mock_entry_no_yaml_config, caplog):
|
||||
async def test_discovery_broken(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
||||
) -> None:
|
||||
"""Test handling of bad discovery message."""
|
||||
data1 = '{ "name": "Beer" }'
|
||||
data2 = (
|
||||
@@ -2726,49 +2774,63 @@ async def test_discovery_broken(hass, mqtt_mock_entry_no_yaml_config, caplog):
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(hass, mqtt_mock_entry_no_yaml_config):
|
||||
async def test_entity_device_info_with_connection(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
||||
) -> None:
|
||||
"""Test MQTT light device registry integration."""
|
||||
await help_test_entity_device_info_with_connection(
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_identifier(hass, mqtt_mock_entry_no_yaml_config):
|
||||
async def test_entity_device_info_with_identifier(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
||||
) -> None:
|
||||
"""Test MQTT light device registry integration."""
|
||||
await help_test_entity_device_info_with_identifier(
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_device_info_update(hass, mqtt_mock_entry_no_yaml_config):
|
||||
async def test_entity_device_info_update(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
||||
) -> None:
|
||||
"""Test device registry update."""
|
||||
await help_test_entity_device_info_update(
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_device_info_remove(hass, mqtt_mock_entry_no_yaml_config):
|
||||
async def test_entity_device_info_remove(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
||||
) -> None:
|
||||
"""Test device registry remove."""
|
||||
await help_test_entity_device_info_remove(
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_id_update_subscriptions(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_entity_id_update_subscriptions(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||
await help_test_entity_id_update_subscriptions(
|
||||
hass, mqtt_mock_entry_with_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_id_update_discovery_update(hass, mqtt_mock_entry_no_yaml_config):
|
||||
async def test_entity_id_update_discovery_update(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
||||
) -> None:
|
||||
"""Test MQTT discovery update when entity_id is updated."""
|
||||
await help_test_entity_id_update_discovery_update(
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_debug_info_message(hass, mqtt_mock_entry_no_yaml_config):
|
||||
async def test_entity_debug_info_message(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
||||
) -> None:
|
||||
"""Test MQTT debug info."""
|
||||
await help_test_entity_debug_info_message(
|
||||
hass,
|
||||
@@ -2779,7 +2841,9 @@ async def test_entity_debug_info_message(hass, mqtt_mock_entry_no_yaml_config):
|
||||
)
|
||||
|
||||
|
||||
async def test_max_mireds(hass, mqtt_mock_entry_with_yaml_config):
|
||||
async def test_max_mireds(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test setting min_mireds and max_mireds."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -2886,7 +2950,7 @@ async def test_max_mireds(hass, mqtt_mock_entry_with_yaml_config):
|
||||
],
|
||||
)
|
||||
async def test_publishing_with_custom_encoding(
|
||||
hass,
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config,
|
||||
caplog,
|
||||
service,
|
||||
@@ -2896,7 +2960,7 @@ async def test_publishing_with_custom_encoding(
|
||||
template,
|
||||
tpl_par,
|
||||
tpl_output,
|
||||
):
|
||||
) -> None:
|
||||
"""Test publishing MQTT payload with different encoding."""
|
||||
domain = light.DOMAIN
|
||||
config = copy.deepcopy(DEFAULT_CONFIG)
|
||||
@@ -2921,7 +2985,9 @@ async def test_publishing_with_custom_encoding(
|
||||
)
|
||||
|
||||
|
||||
async def test_reloadable(hass, mqtt_mock_entry_with_yaml_config, caplog, tmp_path):
|
||||
async def test_reloadable(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog, tmp_path
|
||||
) -> None:
|
||||
"""Test reloading the MQTT platform."""
|
||||
domain = light.DOMAIN
|
||||
config = DEFAULT_CONFIG
|
||||
@@ -2961,7 +3027,7 @@ async def test_reloadable(hass, mqtt_mock_entry_with_yaml_config, caplog, tmp_pa
|
||||
],
|
||||
)
|
||||
async def test_encoding_subscribable_topics(
|
||||
hass,
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config,
|
||||
caplog,
|
||||
topic,
|
||||
@@ -2969,7 +3035,7 @@ async def test_encoding_subscribable_topics(
|
||||
attribute,
|
||||
attribute_value,
|
||||
init_payload,
|
||||
):
|
||||
) -> None:
|
||||
"""Test handling of incoming encoded payload."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][light.DOMAIN])
|
||||
config[CONF_EFFECT_COMMAND_TOPIC] = "light/CONF_EFFECT_COMMAND_TOPIC"
|
||||
@@ -3004,7 +3070,7 @@ async def test_encoding_subscribable_topics(
|
||||
],
|
||||
)
|
||||
async def test_encoding_subscribable_topics_brightness(
|
||||
hass,
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_with_yaml_config,
|
||||
caplog,
|
||||
topic,
|
||||
@@ -3012,7 +3078,7 @@ async def test_encoding_subscribable_topics_brightness(
|
||||
attribute,
|
||||
attribute_value,
|
||||
init_payload,
|
||||
):
|
||||
) -> None:
|
||||
"""Test handling of incoming encoded payload for a brightness only light."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][light.DOMAIN])
|
||||
config[CONF_BRIGHTNESS_COMMAND_TOPIC] = "light/CONF_BRIGHTNESS_COMMAND_TOPIC"
|
||||
@@ -3032,8 +3098,8 @@ async def test_encoding_subscribable_topics_brightness(
|
||||
|
||||
|
||||
async def test_sending_mqtt_brightness_command_with_template(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test the sending of Brightness command with template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -3070,8 +3136,8 @@ async def test_sending_mqtt_brightness_command_with_template(
|
||||
|
||||
|
||||
async def test_sending_mqtt_effect_command_with_template(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test the sending of Effect command with template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -3114,8 +3180,8 @@ async def test_sending_mqtt_effect_command_with_template(
|
||||
|
||||
|
||||
async def test_sending_mqtt_hs_command_with_template(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test the sending of HS Color command with template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -3150,8 +3216,8 @@ async def test_sending_mqtt_hs_command_with_template(
|
||||
|
||||
|
||||
async def test_sending_mqtt_xy_command_with_template(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
||||
) -> None:
|
||||
"""Test the sending of XY Color command with template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -3185,14 +3251,16 @@ async def test_sending_mqtt_xy_command_with_template(
|
||||
assert state.attributes["xy_color"] == (0.151, 0.343)
|
||||
|
||||
|
||||
async def test_setup_manual_entity_from_yaml(hass):
|
||||
async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||
"""Test setup manual configured MQTT entity."""
|
||||
platform = light.DOMAIN
|
||||
await help_test_setup_manual_entity_from_yaml(hass, DEFAULT_CONFIG)
|
||||
assert hass.states.get(f"{platform}.test")
|
||||
|
||||
|
||||
async def test_unload_entry(hass, mqtt_mock_entry_with_yaml_config, tmp_path):
|
||||
async def test_unload_entry(
|
||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, tmp_path
|
||||
) -> None:
|
||||
"""Test unloading the config entry."""
|
||||
domain = light.DOMAIN
|
||||
config = DEFAULT_CONFIG
|
||||
|
Reference in New Issue
Block a user