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:
parent
b0cbe5cb69
commit
df76e31cdf
29 changed files with 1749 additions and 984 deletions
|
@ -1,6 +1,7 @@
|
||||||
"""The tests the MQTT alarm control panel component."""
|
"""The tests the MQTT alarm control panel component."""
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -67,6 +68,7 @@ from .test_common import (
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message
|
from tests.common import async_fire_mqtt_message
|
||||||
from tests.components.alarm_control_panel import common
|
from tests.components.alarm_control_panel import common
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
CODE_NUMBER = "1234"
|
CODE_NUMBER = "1234"
|
||||||
CODE_TEXT = "HELLO_CODE"
|
CODE_TEXT = "HELLO_CODE"
|
||||||
|
@ -181,7 +183,7 @@ async def test_fail_setup_without_state_or_command_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_state_via_state_topic(
|
async def test_update_state_via_state_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test updating with via state topic."""
|
"""Test updating with via state topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -213,7 +215,7 @@ async def test_update_state_via_state_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_ignore_update_state_if_unknown_via_state_topic(
|
async def test_ignore_update_state_if_unknown_via_state_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test ignoring updates via state topic."""
|
"""Test ignoring updates via state topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -245,7 +247,10 @@ async def test_ignore_update_state_if_unknown_via_state_topic(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_publish_mqtt_no_code(
|
async def test_publish_mqtt_no_code(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, service, payload
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
service,
|
||||||
|
payload,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test publishing of MQTT messages when no code is configured."""
|
"""Test publishing of MQTT messages when no code is configured."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -279,7 +284,10 @@ async def test_publish_mqtt_no_code(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_publish_mqtt_with_code(
|
async def test_publish_mqtt_with_code(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, service, payload
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
service,
|
||||||
|
payload,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test publishing of MQTT messages when code is configured."""
|
"""Test publishing of MQTT messages when code is configured."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -332,7 +340,10 @@ async def test_publish_mqtt_with_code(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_publish_mqtt_with_remote_code(
|
async def test_publish_mqtt_with_remote_code(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, service, payload
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
service,
|
||||||
|
payload,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test publishing of MQTT messages when remode code is configured."""
|
"""Test publishing of MQTT messages when remode code is configured."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -376,7 +387,10 @@ async def test_publish_mqtt_with_remote_code(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_publish_mqtt_with_remote_code_text(
|
async def test_publish_mqtt_with_remote_code_text(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, service, payload
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
service,
|
||||||
|
payload,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test publishing of MQTT messages when remote text code is configured."""
|
"""Test publishing of MQTT messages when remote text code is configured."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -421,7 +435,7 @@ async def test_publish_mqtt_with_remote_code_text(
|
||||||
)
|
)
|
||||||
async def test_publish_mqtt_with_code_required_false(
|
async def test_publish_mqtt_with_code_required_false(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
service,
|
service,
|
||||||
payload,
|
payload,
|
||||||
disable_code,
|
disable_code,
|
||||||
|
@ -473,7 +487,7 @@ async def test_publish_mqtt_with_code_required_false(
|
||||||
|
|
||||||
|
|
||||||
async def test_disarm_publishes_mqtt_with_template(
|
async def test_disarm_publishes_mqtt_with_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test publishing of MQTT messages while disarmed.
|
"""Test publishing of MQTT messages while disarmed.
|
||||||
|
|
||||||
|
@ -499,7 +513,7 @@ async def test_disarm_publishes_mqtt_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_state_via_state_topic_template(
|
async def test_update_state_via_state_topic_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test updating with template_value via state topic."""
|
"""Test updating with template_value via state topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -534,7 +548,7 @@ async def test_update_state_via_state_topic_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_attributes_code_number(
|
async def test_attributes_code_number(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attributes which are not supported by the vacuum."""
|
"""Test attributes which are not supported by the vacuum."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG)
|
config = copy.deepcopy(DEFAULT_CONFIG)
|
||||||
|
@ -552,7 +566,7 @@ async def test_attributes_code_number(
|
||||||
|
|
||||||
|
|
||||||
async def test_attributes_remote_code_number(
|
async def test_attributes_remote_code_number(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attributes which are not supported by the vacuum."""
|
"""Test attributes which are not supported by the vacuum."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG_REMOTE_CODE)
|
config = copy.deepcopy(DEFAULT_CONFIG_REMOTE_CODE)
|
||||||
|
@ -570,7 +584,7 @@ async def test_attributes_remote_code_number(
|
||||||
|
|
||||||
|
|
||||||
async def test_attributes_code_text(
|
async def test_attributes_code_text(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attributes which are not supported by the vacuum."""
|
"""Test attributes which are not supported by the vacuum."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG)
|
config = copy.deepcopy(DEFAULT_CONFIG)
|
||||||
|
@ -588,7 +602,7 @@ async def test_attributes_code_text(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -600,7 +614,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -612,7 +626,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_payload(
|
await help_test_default_availability_payload(
|
||||||
|
@ -624,7 +638,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
await help_test_custom_availability_payload(
|
await help_test_custom_availability_payload(
|
||||||
|
@ -636,7 +650,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -648,7 +662,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -661,7 +675,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -673,7 +687,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -686,7 +702,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -699,7 +717,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -737,7 +757,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_alarm(
|
async def test_discovery_removal_alarm(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered alarm_control_panel."""
|
"""Test removal of discovered alarm_control_panel."""
|
||||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][alarm_control_panel.DOMAIN])
|
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][alarm_control_panel.DOMAIN])
|
||||||
|
@ -747,7 +769,9 @@ async def test_discovery_removal_alarm(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_alarm_topic_and_template(
|
async def test_discovery_update_alarm_topic_and_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered alarm_control_panel."""
|
"""Test update of discovered alarm_control_panel."""
|
||||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][alarm_control_panel.DOMAIN])
|
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][alarm_control_panel.DOMAIN])
|
||||||
|
@ -782,7 +806,9 @@ async def test_discovery_update_alarm_topic_and_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_alarm_template(
|
async def test_discovery_update_alarm_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered alarm_control_panel."""
|
"""Test update of discovered alarm_control_panel."""
|
||||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][alarm_control_panel.DOMAIN])
|
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][alarm_control_panel.DOMAIN])
|
||||||
|
@ -815,7 +841,9 @@ async def test_discovery_update_alarm_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_alarm(
|
async def test_discovery_update_unchanged_alarm(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered alarm_control_panel."""
|
"""Test update of discovered alarm_control_panel."""
|
||||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][alarm_control_panel.DOMAIN])
|
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][alarm_control_panel.DOMAIN])
|
||||||
|
@ -837,7 +865,9 @@ async def test_discovery_update_unchanged_alarm(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer" }'
|
data1 = '{ "name": "Beer" }'
|
||||||
|
@ -864,7 +894,11 @@ async def test_discovery_broken(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog, topic, value
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
topic,
|
||||||
|
value,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test handling of incoming encoded payload."""
|
"""Test handling of incoming encoded payload."""
|
||||||
await help_test_encoding_subscribable_topics(
|
await help_test_encoding_subscribable_topics(
|
||||||
|
@ -879,7 +913,7 @@ async def test_encoding_subscribable_topics(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT alarm control panel device registry integration."""
|
"""Test MQTT alarm control panel device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -891,7 +925,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT alarm control panel device registry integration."""
|
"""Test MQTT alarm control panel device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -903,7 +937,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -915,7 +949,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -927,7 +961,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
await help_test_entity_id_update_subscriptions(
|
await help_test_entity_id_update_subscriptions(
|
||||||
|
@ -939,7 +973,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -951,7 +985,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
await help_test_entity_debug_info_message(
|
await help_test_entity_debug_info_message(
|
||||||
|
@ -989,8 +1023,8 @@ async def test_entity_debug_info_message(
|
||||||
)
|
)
|
||||||
async def test_publishing_with_custom_encoding(
|
async def test_publishing_with_custom_encoding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
service,
|
service,
|
||||||
topic,
|
topic,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -1020,7 +1054,10 @@ async def test_publishing_with_custom_encoding(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = alarm_control_panel.DOMAIN
|
domain = alarm_control_panel.DOMAIN
|
||||||
|
@ -1038,7 +1075,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = alarm_control_panel.DOMAIN
|
domain = alarm_control_panel.DOMAIN
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import copy
|
import copy
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import json
|
import json
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -53,6 +54,7 @@ from tests.common import (
|
||||||
async_fire_time_changed,
|
async_fire_time_changed,
|
||||||
mock_restore_cache,
|
mock_restore_cache,
|
||||||
)
|
)
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
@ -72,7 +74,9 @@ def binary_sensor_platform_only():
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_sensor_value_expires_availability_topic(
|
async def test_setting_sensor_value_expires_availability_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the expiration of the value."""
|
"""Test the expiration of the value."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -106,7 +110,9 @@ async def test_setting_sensor_value_expires_availability_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_sensor_value_expires(
|
async def test_setting_sensor_value_expires(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the expiration of the value."""
|
"""Test the expiration of the value."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -185,7 +191,9 @@ async def expires_helper(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_expiration_on_discovery_and_discovery_update_of_binary_sensor(
|
async def test_expiration_on_discovery_and_discovery_update_of_binary_sensor(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that binary_sensor with expire_after set behaves correctly on discovery and discovery update."""
|
"""Test that binary_sensor with expire_after set behaves correctly on discovery and discovery update."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -266,7 +274,7 @@ async def test_expiration_on_discovery_and_discovery_update_of_binary_sensor(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_sensor_value_via_mqtt_message(
|
async def test_setting_sensor_value_via_mqtt_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the value via MQTT."""
|
"""Test the setting of the value via MQTT."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -304,7 +312,9 @@ async def test_setting_sensor_value_via_mqtt_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_invalid_sensor_value_via_mqtt_message(
|
async def test_invalid_sensor_value_via_mqtt_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the value via MQTT."""
|
"""Test the setting of the value via MQTT."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -346,7 +356,7 @@ async def test_invalid_sensor_value_via_mqtt_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_sensor_value_via_mqtt_message_and_template(
|
async def test_setting_sensor_value_via_mqtt_message_and_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the value via MQTT."""
|
"""Test the setting of the value via MQTT."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -381,7 +391,9 @@ async def test_setting_sensor_value_via_mqtt_message_and_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_sensor_value_via_mqtt_message_and_template2(
|
async def test_setting_sensor_value_via_mqtt_message_and_template2(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the value via MQTT."""
|
"""Test the setting of the value via MQTT."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -420,7 +432,9 @@ async def test_setting_sensor_value_via_mqtt_message_and_template2(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_sensor_value_via_mqtt_message_and_template_and_raw_state_encoding(
|
async def test_setting_sensor_value_via_mqtt_message_and_template_and_raw_state_encoding(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test processing a raw value via MQTT."""
|
"""Test processing a raw value via MQTT."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -455,7 +469,7 @@ async def test_setting_sensor_value_via_mqtt_message_and_template_and_raw_state_
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_sensor_value_via_mqtt_message_empty_template(
|
async def test_setting_sensor_value_via_mqtt_message_empty_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the value via MQTT."""
|
"""Test the setting of the value via MQTT."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -489,7 +503,7 @@ async def test_setting_sensor_value_via_mqtt_message_empty_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_valid_device_class(
|
async def test_valid_device_class(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of a valid sensor class."""
|
"""Test the setting of a valid sensor class."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -531,7 +545,7 @@ async def test_invalid_device_class(hass: HomeAssistant, caplog) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -543,7 +557,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -555,7 +569,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_payload(
|
await help_test_default_availability_payload(
|
||||||
|
@ -567,7 +581,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
await help_test_custom_availability_payload(
|
await help_test_custom_availability_payload(
|
||||||
|
@ -579,7 +593,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_force_update_disabled(
|
async def test_force_update_disabled(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test force update option."""
|
"""Test force update option."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -618,7 +632,7 @@ async def test_force_update_disabled(
|
||||||
|
|
||||||
|
|
||||||
async def test_force_update_enabled(
|
async def test_force_update_enabled(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test force update option."""
|
"""Test force update option."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -707,7 +721,7 @@ async def test_off_delay(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -719,7 +733,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -731,7 +745,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -744,7 +760,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -757,7 +775,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -793,7 +813,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_binary_sensor(
|
async def test_discovery_removal_binary_sensor(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered binary_sensor."""
|
"""Test removal of discovered binary_sensor."""
|
||||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][binary_sensor.DOMAIN])
|
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][binary_sensor.DOMAIN])
|
||||||
|
@ -803,7 +825,9 @@ async def test_discovery_removal_binary_sensor(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_binary_sensor_topic_template(
|
async def test_discovery_update_binary_sensor_topic_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered binary_sensor."""
|
"""Test update of discovered binary_sensor."""
|
||||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][binary_sensor.DOMAIN])
|
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][binary_sensor.DOMAIN])
|
||||||
|
@ -840,7 +864,9 @@ async def test_discovery_update_binary_sensor_topic_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_binary_sensor_template(
|
async def test_discovery_update_binary_sensor_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered binary_sensor."""
|
"""Test update of discovered binary_sensor."""
|
||||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][binary_sensor.DOMAIN])
|
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][binary_sensor.DOMAIN])
|
||||||
|
@ -889,8 +915,8 @@ async def test_discovery_update_binary_sensor_template(
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
@ -911,7 +937,9 @@ async def test_encoding_subscribable_topics(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_binary_sensor(
|
async def test_discovery_update_unchanged_binary_sensor(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered binary_sensor."""
|
"""Test update of discovered binary_sensor."""
|
||||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][binary_sensor.DOMAIN])
|
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][binary_sensor.DOMAIN])
|
||||||
|
@ -933,7 +961,9 @@ async def test_discovery_update_unchanged_binary_sensor(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer",' ' "off_delay": -1 }'
|
data1 = '{ "name": "Beer",' ' "off_delay": -1 }'
|
||||||
|
@ -949,7 +979,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT binary sensor device registry integration."""
|
"""Test MQTT binary sensor device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -961,7 +991,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT binary sensor device registry integration."""
|
"""Test MQTT binary sensor device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -973,7 +1003,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -985,7 +1015,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -997,7 +1027,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
await help_test_entity_id_update_subscriptions(
|
await help_test_entity_id_update_subscriptions(
|
||||||
|
@ -1009,7 +1039,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -1021,7 +1051,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
await help_test_entity_debug_info_message(
|
await help_test_entity_debug_info_message(
|
||||||
|
@ -1034,7 +1064,10 @@ async def test_entity_debug_info_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = binary_sensor.DOMAIN
|
domain = binary_sensor.DOMAIN
|
||||||
|
@ -1050,9 +1083,9 @@ async def test_reloadable(
|
||||||
)
|
)
|
||||||
async def test_cleanup_triggers_and_restoring_state(
|
async def test_cleanup_triggers_and_restoring_state(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
tmp_path,
|
tmp_path: Path,
|
||||||
freezer,
|
freezer,
|
||||||
payload1,
|
payload1,
|
||||||
state1,
|
state1,
|
||||||
|
@ -1110,7 +1143,9 @@ async def test_cleanup_triggers_and_restoring_state(
|
||||||
|
|
||||||
|
|
||||||
async def test_skip_restoring_state_with_over_due_expire_trigger(
|
async def test_skip_restoring_state_with_over_due_expire_trigger(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, freezer
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
freezer,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test restoring a state with over due expire timer."""
|
"""Test restoring a state with over due expire timer."""
|
||||||
|
|
||||||
|
@ -1145,7 +1180,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = binary_sensor.DOMAIN
|
domain = binary_sensor.DOMAIN
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""The tests for the MQTT button platform."""
|
"""The tests for the MQTT button platform."""
|
||||||
import copy
|
import copy
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -42,6 +43,8 @@ from .test_common import (
|
||||||
help_test_update_with_json_attrs_not_dict,
|
help_test_update_with_json_attrs_not_dict,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {button.DOMAIN: {"name": "test", "command_topic": "test-topic"}}
|
mqtt.DOMAIN: {button.DOMAIN: {"name": "test", "command_topic": "test-topic"}}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +59,7 @@ def button_platform_only():
|
||||||
|
|
||||||
@pytest.mark.freeze_time("2021-11-08 13:31:44+00:00")
|
@pytest.mark.freeze_time("2021-11-08 13:31:44+00:00")
|
||||||
async def test_sending_mqtt_commands(
|
async def test_sending_mqtt_commands(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending MQTT commands."""
|
"""Test the sending MQTT commands."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -97,7 +100,7 @@ async def test_sending_mqtt_commands(
|
||||||
|
|
||||||
|
|
||||||
async def test_command_template(
|
async def test_command_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending of MQTT commands through a command template."""
|
"""Test the sending of MQTT commands through a command template."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -135,7 +138,7 @@ async def test_command_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -144,7 +147,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -153,7 +156,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -178,7 +181,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -203,7 +206,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -212,7 +215,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -221,7 +224,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -230,7 +233,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -243,7 +248,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -256,7 +263,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -292,7 +301,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_button(
|
async def test_discovery_removal_button(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered button."""
|
"""Test removal of discovered button."""
|
||||||
data = '{ "name": "test", "command_topic": "test_topic" }'
|
data = '{ "name": "test", "command_topic": "test_topic" }'
|
||||||
|
@ -302,7 +313,9 @@ async def test_discovery_removal_button(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_button(
|
async def test_discovery_update_button(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered button."""
|
"""Test update of discovered button."""
|
||||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][button.DOMAIN])
|
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][button.DOMAIN])
|
||||||
|
@ -321,7 +334,9 @@ async def test_discovery_update_button(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_button(
|
async def test_discovery_update_unchanged_button(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered button."""
|
"""Test update of discovered button."""
|
||||||
data1 = (
|
data1 = (
|
||||||
|
@ -344,7 +359,9 @@ async def test_discovery_update_unchanged_button(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer" }'
|
data1 = '{ "name": "Beer" }'
|
||||||
|
@ -355,7 +372,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT button device registry integration."""
|
"""Test MQTT button device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -364,7 +381,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT button device registry integration."""
|
"""Test MQTT button device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -373,7 +390,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -382,7 +399,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -391,7 +408,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -400,7 +417,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
await help_test_entity_debug_info_message(
|
await help_test_entity_debug_info_message(
|
||||||
|
@ -432,7 +449,7 @@ async def test_invalid_device_class(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_valid_device_class(
|
async def test_valid_device_class(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test device_class option with valid values."""
|
"""Test device_class option with valid values."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -478,8 +495,8 @@ async def test_valid_device_class(
|
||||||
)
|
)
|
||||||
async def test_publishing_with_custom_encoding(
|
async def test_publishing_with_custom_encoding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
service,
|
service,
|
||||||
topic,
|
topic,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -505,7 +522,10 @@ async def test_publishing_with_custom_encoding(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = button.DOMAIN
|
domain = button.DOMAIN
|
||||||
|
@ -523,7 +543,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = button.DOMAIN
|
domain = button.DOMAIN
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import json
|
import json
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -41,6 +42,7 @@ from .test_common import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message
|
from tests.common import async_fire_mqtt_message
|
||||||
|
from tests.typing import ClientSessionGenerator, MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {mqtt.DOMAIN: {camera.DOMAIN: {"name": "test", "topic": "test_topic"}}}
|
DEFAULT_CONFIG = {mqtt.DOMAIN: {camera.DOMAIN: {"name": "test", "topic": "test_topic"}}}
|
||||||
|
|
||||||
|
@ -53,7 +55,9 @@ def camera_platform_only():
|
||||||
|
|
||||||
|
|
||||||
async def test_run_camera_setup(
|
async def test_run_camera_setup(
|
||||||
hass: HomeAssistant, hass_client_no_auth, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant,
|
||||||
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that it fetches the given payload."""
|
"""Test that it fetches the given payload."""
|
||||||
topic = "test/camera"
|
topic = "test/camera"
|
||||||
|
@ -77,7 +81,9 @@ async def test_run_camera_setup(
|
||||||
|
|
||||||
|
|
||||||
async def test_run_camera_b64_encoded(
|
async def test_run_camera_b64_encoded(
|
||||||
hass: HomeAssistant, hass_client_no_auth, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant,
|
||||||
|
hass_client_no_auth,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that it fetches the given encoded payload."""
|
"""Test that it fetches the given encoded payload."""
|
||||||
topic = "test/camera"
|
topic = "test/camera"
|
||||||
|
@ -109,7 +115,9 @@ async def test_run_camera_b64_encoded(
|
||||||
|
|
||||||
|
|
||||||
async def test_camera_b64_encoded_with_availability(
|
async def test_camera_b64_encoded_with_availability(
|
||||||
hass: HomeAssistant, hass_client_no_auth, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant,
|
||||||
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability works if b64 encoding is turned on."""
|
"""Test availability works if b64 encoding is turned on."""
|
||||||
topic = "test/camera"
|
topic = "test/camera"
|
||||||
|
@ -147,7 +155,7 @@ async def test_camera_b64_encoded_with_availability(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -156,7 +164,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -165,7 +173,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_payload(
|
await help_test_default_availability_payload(
|
||||||
|
@ -174,7 +182,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
await help_test_custom_availability_payload(
|
await help_test_custom_availability_payload(
|
||||||
|
@ -183,7 +191,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -192,7 +200,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -205,7 +213,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -214,7 +222,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -227,7 +237,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -240,7 +252,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -276,7 +290,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_camera(
|
async def test_discovery_removal_camera(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered camera."""
|
"""Test removal of discovered camera."""
|
||||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][camera.DOMAIN])
|
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][camera.DOMAIN])
|
||||||
|
@ -286,7 +302,9 @@ async def test_discovery_removal_camera(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_camera(
|
async def test_discovery_update_camera(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered camera."""
|
"""Test update of discovered camera."""
|
||||||
config1 = {"name": "Beer", "topic": "test_topic"}
|
config1 = {"name": "Beer", "topic": "test_topic"}
|
||||||
|
@ -298,7 +316,9 @@ async def test_discovery_update_camera(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_camera(
|
async def test_discovery_update_unchanged_camera(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered camera."""
|
"""Test update of discovered camera."""
|
||||||
data1 = '{ "name": "Beer", "topic": "test_topic"}'
|
data1 = '{ "name": "Beer", "topic": "test_topic"}'
|
||||||
|
@ -317,7 +337,9 @@ async def test_discovery_update_unchanged_camera(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer" }'
|
data1 = '{ "name": "Beer" }'
|
||||||
|
@ -329,7 +351,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT camera device registry integration."""
|
"""Test MQTT camera device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -338,7 +360,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT camera device registry integration."""
|
"""Test MQTT camera device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -347,7 +369,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -356,7 +378,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -365,7 +387,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
await help_test_entity_id_update_subscriptions(
|
await help_test_entity_id_update_subscriptions(
|
||||||
|
@ -378,7 +400,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -387,7 +409,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
await help_test_entity_debug_info_message(
|
await help_test_entity_debug_info_message(
|
||||||
|
@ -402,7 +424,10 @@ async def test_entity_debug_info_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = camera.DOMAIN
|
domain = camera.DOMAIN
|
||||||
|
@ -420,7 +445,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = camera.DOMAIN
|
domain = camera.DOMAIN
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""The tests for the mqtt climate component."""
|
"""The tests for the mqtt climate component."""
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import call, patch
|
from unittest.mock import call, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -63,6 +64,7 @@ from .test_common import (
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message
|
from tests.common import async_fire_mqtt_message
|
||||||
from tests.components.climate import common
|
from tests.components.climate import common
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
ENTITY_CLIMATE = "climate.test"
|
ENTITY_CLIMATE = "climate.test"
|
||||||
|
|
||||||
|
@ -102,7 +104,7 @@ def climate_platform_only():
|
||||||
|
|
||||||
|
|
||||||
async def test_setup_params(
|
async def test_setup_params(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the initial parameters."""
|
"""Test the initial parameters."""
|
||||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
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(
|
async def test_preset_modes_deprecation_guard(
|
||||||
hass: HomeAssistant, caplog, parameter, config_value
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, parameter, config_value
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the configuration for invalid legacy parameters."""
|
"""Test the configuration for invalid legacy parameters."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][climate.DOMAIN])
|
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(
|
async def test_supported_features(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the supported_features."""
|
"""Test the supported_features."""
|
||||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
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(
|
async def test_get_hvac_modes(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that the operation list returns the correct modes."""
|
"""Test that the operation list returns the correct modes."""
|
||||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
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(
|
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:
|
) -> None:
|
||||||
"""Test setting operation mode without required attribute.
|
"""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(
|
async def test_set_operation(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting of new operation mode."""
|
"""Test setting of new operation mode."""
|
||||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
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(
|
async def test_set_operation_pessimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting operation mode in pessimistic mode."""
|
"""Test setting operation mode in pessimistic mode."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -263,7 +267,7 @@ async def test_set_operation_pessimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_set_operation_optimistic(
|
async def test_set_operation_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting operation mode in optimistic mode."""
|
"""Test setting operation mode in optimistic mode."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
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 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
|
# support was deprecated with release 2023.2 and will be removed with release 2023.8
|
||||||
async def test_set_operation_with_power_command(
|
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:
|
) -> None:
|
||||||
"""Test setting of new operation mode with power command enabled."""
|
"""Test setting of new operation mode with power command enabled."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
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(
|
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:
|
) -> None:
|
||||||
"""Test setting fan mode without required attribute."""
|
"""Test setting fan mode without required attribute."""
|
||||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
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(
|
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:
|
) -> None:
|
||||||
"""Test setting of new fan mode in pessimistic mode."""
|
"""Test setting of new fan mode in pessimistic mode."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
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(
|
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:
|
) -> None:
|
||||||
"""Test setting of new fan mode in optimistic mode."""
|
"""Test setting of new fan mode in optimistic mode."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -394,7 +400,7 @@ async def test_set_fan_mode_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_set_fan_mode(
|
async def test_set_fan_mode(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting of new fan mode."""
|
"""Test setting of new fan mode."""
|
||||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
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(
|
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:
|
) -> None:
|
||||||
"""Test setting swing mode without required attribute."""
|
"""Test setting swing mode without required attribute."""
|
||||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
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(
|
async def test_set_swing_pessimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting swing mode in pessimistic mode."""
|
"""Test setting swing mode in pessimistic mode."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -455,7 +463,7 @@ async def test_set_swing_pessimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_set_swing_optimistic(
|
async def test_set_swing_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting swing mode in optimistic mode."""
|
"""Test setting swing mode in optimistic mode."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
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(
|
async def test_set_target_temperature(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting the target temperature."""
|
"""Test setting the target temperature."""
|
||||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
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(
|
async def test_set_target_humidity(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting the target humidity."""
|
"""Test setting the target humidity."""
|
||||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
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(
|
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:
|
) -> None:
|
||||||
"""Test setting the target temperature."""
|
"""Test setting the target temperature."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
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(
|
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:
|
) -> None:
|
||||||
"""Test setting the target temperature optimistic."""
|
"""Test setting the target temperature optimistic."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
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(
|
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:
|
) -> None:
|
||||||
"""Test setting the low/high target temperature."""
|
"""Test setting the low/high target temperature."""
|
||||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
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(
|
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:
|
) -> None:
|
||||||
"""Test setting the low/high target temperature."""
|
"""Test setting the low/high target temperature."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
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(
|
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:
|
) -> None:
|
||||||
"""Test setting the low/high target temperature optimistic."""
|
"""Test setting the low/high target temperature optimistic."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
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(
|
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:
|
) -> None:
|
||||||
"""Test setting the target humidity optimistic."""
|
"""Test setting the target humidity optimistic."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
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(
|
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:
|
) -> None:
|
||||||
"""Test setting the target humidity."""
|
"""Test setting the target humidity."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -755,7 +763,7 @@ async def test_set_target_humidity_pessimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_receive_mqtt_temperature(
|
async def test_receive_mqtt_temperature(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test getting the current temperature via MQTT."""
|
"""Test getting the current temperature via MQTT."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -770,7 +778,7 @@ async def test_receive_mqtt_temperature(
|
||||||
|
|
||||||
|
|
||||||
async def test_receive_mqtt_humidity(
|
async def test_receive_mqtt_humidity(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test getting the current humidity via MQTT."""
|
"""Test getting the current humidity via MQTT."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -785,7 +793,7 @@ async def test_receive_mqtt_humidity(
|
||||||
|
|
||||||
|
|
||||||
async def test_handle_target_humidity_received(
|
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:
|
) -> None:
|
||||||
"""Test setting the target humidity via MQTT."""
|
"""Test setting the target humidity via MQTT."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -804,7 +812,7 @@ async def test_handle_target_humidity_received(
|
||||||
|
|
||||||
|
|
||||||
async def test_handle_action_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:
|
) -> None:
|
||||||
"""Test getting the action received via MQTT."""
|
"""Test getting the action received via MQTT."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -829,7 +837,9 @@ async def test_handle_action_received(
|
||||||
|
|
||||||
|
|
||||||
async def test_set_preset_mode_optimistic(
|
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:
|
) -> None:
|
||||||
"""Test setting of the preset mode."""
|
"""Test setting of the preset mode."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
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(
|
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:
|
) -> None:
|
||||||
"""Test setting of the preset mode."""
|
"""Test setting of the preset mode."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
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(
|
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:
|
) -> None:
|
||||||
"""Test setting of the preset mode."""
|
"""Test setting of the preset mode."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -974,7 +988,7 @@ async def test_set_preset_mode_pessimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_set_aux_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:
|
) -> None:
|
||||||
"""Test setting of the aux heating in pessimistic mode."""
|
"""Test setting of the aux heating in pessimistic mode."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
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(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -1033,7 +1047,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -1042,7 +1056,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_payload(
|
await help_test_default_availability_payload(
|
||||||
|
@ -1051,7 +1065,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
await help_test_custom_availability_payload(
|
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(
|
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:
|
) -> None:
|
||||||
"""Test getting temperature high/low with templates."""
|
"""Test getting temperature high/low with templates."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
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(
|
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:
|
) -> None:
|
||||||
"""Test getting various attributes with templates."""
|
"""Test getting various attributes with templates."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -1217,7 +1235,9 @@ async def test_get_with_templates(
|
||||||
|
|
||||||
|
|
||||||
async def test_set_and_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:
|
) -> None:
|
||||||
"""Test setting various attributes with templates."""
|
"""Test setting various attributes with templates."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -1307,7 +1327,7 @@ async def test_set_and_templates(
|
||||||
|
|
||||||
|
|
||||||
async def test_min_temp_custom(
|
async def test_min_temp_custom(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test a custom min temp."""
|
"""Test a custom min temp."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -1325,7 +1345,7 @@ async def test_min_temp_custom(
|
||||||
|
|
||||||
|
|
||||||
async def test_max_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:
|
) -> None:
|
||||||
"""Test a custom max temp."""
|
"""Test a custom max temp."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -1343,7 +1363,7 @@ async def test_max_temp_custom(
|
||||||
|
|
||||||
|
|
||||||
async def test_min_humidity_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:
|
) -> None:
|
||||||
"""Test a custom min humidity."""
|
"""Test a custom min humidity."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -1361,7 +1381,7 @@ async def test_min_humidity_custom(
|
||||||
|
|
||||||
|
|
||||||
async def test_max_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:
|
) -> None:
|
||||||
"""Test a custom max humidity."""
|
"""Test a custom max humidity."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -1379,7 +1399,7 @@ async def test_max_humidity_custom(
|
||||||
|
|
||||||
|
|
||||||
async def test_temp_step_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:
|
) -> None:
|
||||||
"""Test a custom temp step."""
|
"""Test a custom temp step."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -1397,7 +1417,7 @@ async def test_temp_step_custom(
|
||||||
|
|
||||||
|
|
||||||
async def test_temperature_unit(
|
async def test_temperature_unit(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that setting temperature unit converts temperature values."""
|
"""Test that setting temperature unit converts temperature values."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
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(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
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(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
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(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
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(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
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(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
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(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
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(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
@ -1552,7 +1578,9 @@ async def test_encoding_subscribable_topics(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_climate(
|
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:
|
) -> None:
|
||||||
"""Test removal of discovered climate."""
|
"""Test removal of discovered climate."""
|
||||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][climate.DOMAIN])
|
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(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered climate."""
|
"""Test update of discovered climate."""
|
||||||
config1 = {"name": "Beer"}
|
config1 = {"name": "Beer"}
|
||||||
|
@ -1573,7 +1603,9 @@ async def test_discovery_update_climate(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_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:
|
) -> None:
|
||||||
"""Test update of discovered climate."""
|
"""Test update of discovered climate."""
|
||||||
data1 = '{ "name": "Beer" }'
|
data1 = '{ "name": "Beer" }'
|
||||||
|
@ -1592,7 +1624,9 @@ async def test_discovery_update_unchanged_climate(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer", "power_command_topic": "test_topic#" }'
|
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(
|
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:
|
) -> None:
|
||||||
"""Test MQTT climate device registry integration."""
|
"""Test MQTT climate device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
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(
|
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:
|
) -> None:
|
||||||
"""Test MQTT climate device registry integration."""
|
"""Test MQTT climate device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
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(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_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(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_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(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1661,7 +1695,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
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(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1695,7 +1729,7 @@ async def test_entity_debug_info_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_precision_default(
|
async def test_precision_default(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that setting precision to tenths works as intended."""
|
"""Test that setting precision to tenths works as intended."""
|
||||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
||||||
|
@ -1711,7 +1745,7 @@ async def test_precision_default(
|
||||||
|
|
||||||
|
|
||||||
async def test_precision_halves(
|
async def test_precision_halves(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that setting precision to halves works as intended."""
|
"""Test that setting precision to halves works as intended."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -1729,7 +1763,7 @@ async def test_precision_halves(
|
||||||
|
|
||||||
|
|
||||||
async def test_precision_whole(
|
async def test_precision_whole(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that setting precision to whole works as intended."""
|
"""Test that setting precision to whole works as intended."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN])
|
||||||
|
@ -1831,8 +1865,8 @@ async def test_precision_whole(
|
||||||
)
|
)
|
||||||
async def test_publishing_with_custom_encoding(
|
async def test_publishing_with_custom_encoding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
service,
|
service,
|
||||||
topic,
|
topic,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -1919,7 +1953,10 @@ async def test_humidity_configuration_validity(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = climate.DOMAIN
|
domain = climate.DOMAIN
|
||||||
|
@ -1937,7 +1974,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = climate.DOMAIN
|
domain = climate.DOMAIN
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
"""Test config flow."""
|
"""Test config flow."""
|
||||||
|
from pathlib import Path
|
||||||
from random import getrandbits
|
from random import getrandbits
|
||||||
from ssl import SSLError
|
from ssl import SSLError
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
@ -15,6 +16,7 @@ from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
from tests.typing import MqttMockHAClientGenerator, MqttMockPahoClient
|
||||||
|
|
||||||
MOCK_CLIENT_CERT = b"## mock client certificate file ##"
|
MOCK_CLIENT_CERT = b"## mock client certificate file ##"
|
||||||
MOCK_CLIENT_KEY = b"## mock key file ##"
|
MOCK_CLIENT_KEY = b"## mock key file ##"
|
||||||
|
@ -167,7 +169,10 @@ def mock_process_uploaded_file(tmp_path):
|
||||||
|
|
||||||
|
|
||||||
async def test_user_connection_works(
|
async def test_user_connection_works(
|
||||||
hass: HomeAssistant, mock_try_connection, mock_finish_setup, mqtt_client_mock
|
hass: HomeAssistant,
|
||||||
|
mock_try_connection,
|
||||||
|
mock_finish_setup,
|
||||||
|
mqtt_client_mock: MqttMockPahoClient,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we can finish a config flow."""
|
"""Test we can finish a config flow."""
|
||||||
mock_try_connection.return_value = True
|
mock_try_connection.return_value = True
|
||||||
|
@ -195,7 +200,10 @@ async def test_user_connection_works(
|
||||||
|
|
||||||
|
|
||||||
async def test_user_v5_connection_works(
|
async def test_user_v5_connection_works(
|
||||||
hass: HomeAssistant, mock_try_connection, mock_finish_setup, mqtt_client_mock
|
hass: HomeAssistant,
|
||||||
|
mock_try_connection,
|
||||||
|
mock_finish_setup,
|
||||||
|
mqtt_client_mock: MqttMockPahoClient,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we can finish a config flow."""
|
"""Test we can finish a config flow."""
|
||||||
mock_try_connection.return_value = True
|
mock_try_connection.return_value = True
|
||||||
|
@ -256,7 +264,10 @@ async def test_user_connection_fails(
|
||||||
|
|
||||||
|
|
||||||
async def test_manual_config_starts_discovery_flow(
|
async def test_manual_config_starts_discovery_flow(
|
||||||
hass: HomeAssistant, mock_try_connection, mock_finish_setup, mqtt_client_mock
|
hass: HomeAssistant,
|
||||||
|
mock_try_connection,
|
||||||
|
mock_finish_setup,
|
||||||
|
mqtt_client_mock: MqttMockPahoClient,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test manual config initiates a discovery flow."""
|
"""Test manual config initiates a discovery flow."""
|
||||||
# No flows in progress
|
# No flows in progress
|
||||||
|
@ -279,7 +290,7 @@ async def test_manual_config_set(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_try_connection,
|
mock_try_connection,
|
||||||
mock_finish_setup,
|
mock_finish_setup,
|
||||||
mqtt_client_mock,
|
mqtt_client_mock: MqttMockPahoClient,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test manual config does not create an entry, and entry can be setup late."""
|
"""Test manual config does not create an entry, and entry can be setup late."""
|
||||||
# MQTT config present in yaml config
|
# MQTT config present in yaml config
|
||||||
|
@ -458,7 +469,7 @@ async def test_hassio_cannot_connect(
|
||||||
|
|
||||||
async def test_option_flow(
|
async def test_option_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_no_yaml_config,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
mock_try_connection,
|
mock_try_connection,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test config flow options."""
|
"""Test config flow options."""
|
||||||
|
@ -555,9 +566,9 @@ async def test_option_flow(
|
||||||
)
|
)
|
||||||
async def test_bad_certificate(
|
async def test_bad_certificate(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_no_yaml_config,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
mock_try_connection_success,
|
mock_try_connection_success,
|
||||||
tmp_path,
|
tmp_path: Path,
|
||||||
mock_ssl_context,
|
mock_ssl_context,
|
||||||
test_error,
|
test_error,
|
||||||
mock_process_uploaded_file,
|
mock_process_uploaded_file,
|
||||||
|
@ -652,7 +663,7 @@ async def test_bad_certificate(
|
||||||
)
|
)
|
||||||
async def test_keepalive_validation(
|
async def test_keepalive_validation(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_no_yaml_config,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
mock_try_connection,
|
mock_try_connection,
|
||||||
mock_reload_after_entry_update,
|
mock_reload_after_entry_update,
|
||||||
input_value,
|
input_value,
|
||||||
|
@ -698,7 +709,7 @@ async def test_keepalive_validation(
|
||||||
|
|
||||||
async def test_disable_birth_will(
|
async def test_disable_birth_will(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_no_yaml_config,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
mock_try_connection,
|
mock_try_connection,
|
||||||
mock_reload_after_entry_update,
|
mock_reload_after_entry_update,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -769,7 +780,7 @@ async def test_disable_birth_will(
|
||||||
|
|
||||||
async def test_invalid_discovery_prefix(
|
async def test_invalid_discovery_prefix(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_no_yaml_config,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
mock_try_connection,
|
mock_try_connection,
|
||||||
mock_reload_after_entry_update,
|
mock_reload_after_entry_update,
|
||||||
) -> HomeAssistant:
|
) -> HomeAssistant:
|
||||||
|
@ -845,7 +856,7 @@ def get_suggested(schema, key):
|
||||||
|
|
||||||
async def test_option_flow_default_suggested_values(
|
async def test_option_flow_default_suggested_values(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_no_yaml_config,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
mock_try_connection_success,
|
mock_try_connection_success,
|
||||||
mock_reload_after_entry_update,
|
mock_reload_after_entry_update,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -1000,7 +1011,7 @@ async def test_option_flow_default_suggested_values(
|
||||||
)
|
)
|
||||||
async def test_skipping_advanced_options(
|
async def test_skipping_advanced_options(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_no_yaml_config,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
mock_try_connection,
|
mock_try_connection,
|
||||||
mock_reload_after_entry_update,
|
mock_reload_after_entry_update,
|
||||||
advanced_options,
|
advanced_options,
|
||||||
|
@ -1146,7 +1157,7 @@ async def test_options_bad_will_message_fails(
|
||||||
async def test_try_connection_with_advanced_parameters(
|
async def test_try_connection_with_advanced_parameters(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_try_connection_success,
|
mock_try_connection_success,
|
||||||
tmp_path,
|
tmp_path: Path,
|
||||||
mock_ssl_context,
|
mock_ssl_context,
|
||||||
mock_process_uploaded_file,
|
mock_process_uploaded_file,
|
||||||
) -> HomeAssistant:
|
) -> HomeAssistant:
|
||||||
|
@ -1287,7 +1298,7 @@ async def test_try_connection_with_advanced_parameters(
|
||||||
async def test_setup_with_advanced_settings(
|
async def test_setup_with_advanced_settings(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_try_connection,
|
mock_try_connection,
|
||||||
tmp_path,
|
tmp_path: Path,
|
||||||
mock_ssl_context,
|
mock_ssl_context,
|
||||||
mock_process_uploaded_file,
|
mock_process_uploaded_file,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -1445,7 +1456,7 @@ async def test_setup_with_advanced_settings(
|
||||||
async def test_change_websockets_transport_to_tcp(
|
async def test_change_websockets_transport_to_tcp(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_try_connection,
|
mock_try_connection,
|
||||||
tmp_path,
|
tmp_path: Path,
|
||||||
mock_ssl_context,
|
mock_ssl_context,
|
||||||
mock_process_uploaded_file,
|
mock_process_uploaded_file,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"""The tests for the MQTT cover platform."""
|
"""The tests for the MQTT cover platform."""
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -78,6 +78,7 @@ from .test_common import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message
|
from tests.common import async_fire_mqtt_message
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {cover.DOMAIN: {"name": "test", "state_topic": "test-topic"}}
|
mqtt.DOMAIN: {cover.DOMAIN: {"name": "test", "state_topic": "test-topic"}}
|
||||||
|
@ -92,7 +93,7 @@ def cover_platform_only():
|
||||||
|
|
||||||
|
|
||||||
async def test_state_via_state_topic(
|
async def test_state_via_state_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic."""
|
"""Test the controlling state via topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -131,7 +132,7 @@ async def test_state_via_state_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_opening_and_closing_state_via_custom_state_payload(
|
async def test_opening_and_closing_state_via_custom_state_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling opening and closing state via a custom payload."""
|
"""Test the controlling opening and closing state via a custom payload."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -177,7 +178,7 @@ async def test_opening_and_closing_state_via_custom_state_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_open_closed_state_from_position_optimistic(
|
async def test_open_closed_state_from_position_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the state after setting the position using optimistic mode."""
|
"""Test the state after setting the position using optimistic mode."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -228,7 +229,7 @@ async def test_open_closed_state_from_position_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_position_via_position_topic(
|
async def test_position_via_position_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic."""
|
"""Test the controlling state via topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -269,7 +270,7 @@ async def test_position_via_position_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_state_via_template(
|
async def test_state_via_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic."""
|
"""Test the controlling state via topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -310,7 +311,7 @@ async def test_state_via_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_state_via_template_and_entity_id(
|
async def test_state_via_template_and_entity_id(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic."""
|
"""Test the controlling state via topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -353,7 +354,9 @@ async def test_state_via_template_and_entity_id(
|
||||||
|
|
||||||
|
|
||||||
async def test_state_via_template_with_json_value(
|
async def test_state_via_template_with_json_value(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic with JSON value."""
|
"""Test the controlling state via topic with JSON value."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -396,7 +399,7 @@ async def test_state_via_template_with_json_value(
|
||||||
|
|
||||||
|
|
||||||
async def test_position_via_template_and_entity_id(
|
async def test_position_via_template_and_entity_id(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic."""
|
"""Test the controlling state via topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -452,7 +455,10 @@ async def test_position_via_template_and_entity_id(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_optimistic_flag(
|
async def test_optimistic_flag(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, config, assumed_state
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
config,
|
||||||
|
assumed_state,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test assumed_state is set correctly."""
|
"""Test assumed_state is set correctly."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -472,7 +478,7 @@ async def test_optimistic_flag(
|
||||||
|
|
||||||
|
|
||||||
async def test_optimistic_state_change(
|
async def test_optimistic_state_change(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test changing state optimistically."""
|
"""Test changing state optimistically."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -532,7 +538,7 @@ async def test_optimistic_state_change(
|
||||||
|
|
||||||
|
|
||||||
async def test_optimistic_state_change_with_position(
|
async def test_optimistic_state_change_with_position(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test changing state optimistically."""
|
"""Test changing state optimistically."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -599,7 +605,7 @@ async def test_optimistic_state_change_with_position(
|
||||||
|
|
||||||
|
|
||||||
async def test_send_open_cover_command(
|
async def test_send_open_cover_command(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending of open_cover."""
|
"""Test the sending of open_cover."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -632,7 +638,7 @@ async def test_send_open_cover_command(
|
||||||
|
|
||||||
|
|
||||||
async def test_send_close_cover_command(
|
async def test_send_close_cover_command(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending of close_cover."""
|
"""Test the sending of close_cover."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -665,7 +671,7 @@ async def test_send_close_cover_command(
|
||||||
|
|
||||||
|
|
||||||
async def test_send_stop__cover_command(
|
async def test_send_stop__cover_command(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending of stop_cover."""
|
"""Test the sending of stop_cover."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -698,7 +704,7 @@ async def test_send_stop__cover_command(
|
||||||
|
|
||||||
|
|
||||||
async def test_current_cover_position(
|
async def test_current_cover_position(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the current cover position."""
|
"""Test the current cover position."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -753,7 +759,7 @@ async def test_current_cover_position(
|
||||||
|
|
||||||
|
|
||||||
async def test_current_cover_position_inverted(
|
async def test_current_cover_position_inverted(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the current cover position."""
|
"""Test the current cover position."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -840,7 +846,7 @@ async def test_optimistic_position(hass: HomeAssistant, caplog) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_position_update(
|
async def test_position_update(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test cover position update from received MQTT message."""
|
"""Test cover position update from received MQTT message."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -886,7 +892,7 @@ async def test_position_update(
|
||||||
)
|
)
|
||||||
async def test_set_position_templated(
|
async def test_set_position_templated(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
pos_template,
|
pos_template,
|
||||||
pos_call,
|
pos_call,
|
||||||
pos_message,
|
pos_message,
|
||||||
|
@ -928,7 +934,7 @@ async def test_set_position_templated(
|
||||||
|
|
||||||
|
|
||||||
async def test_set_position_templated_and_attributes(
|
async def test_set_position_templated_and_attributes(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting cover position via template and using entities attributes."""
|
"""Test setting cover position via template and using entities attributes."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -974,7 +980,7 @@ async def test_set_position_templated_and_attributes(
|
||||||
|
|
||||||
|
|
||||||
async def test_set_tilt_templated(
|
async def test_set_tilt_templated(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting cover tilt position via template."""
|
"""Test setting cover tilt position via template."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1015,7 +1021,7 @@ async def test_set_tilt_templated(
|
||||||
|
|
||||||
|
|
||||||
async def test_set_tilt_templated_and_attributes(
|
async def test_set_tilt_templated_and_attributes(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting cover tilt position via template and using entities attributes."""
|
"""Test setting cover tilt position via template and using entities attributes."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1105,7 +1111,7 @@ async def test_set_tilt_templated_and_attributes(
|
||||||
|
|
||||||
|
|
||||||
async def test_set_position_untemplated(
|
async def test_set_position_untemplated(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting cover position via template."""
|
"""Test setting cover position via template."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1139,7 +1145,7 @@ async def test_set_position_untemplated(
|
||||||
|
|
||||||
|
|
||||||
async def test_set_position_untemplated_custom_percentage_range(
|
async def test_set_position_untemplated_custom_percentage_range(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting cover position via template."""
|
"""Test setting cover position via template."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1175,7 +1181,7 @@ async def test_set_position_untemplated_custom_percentage_range(
|
||||||
|
|
||||||
|
|
||||||
async def test_no_command_topic(
|
async def test_no_command_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test with no command topic."""
|
"""Test with no command topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1202,7 +1208,7 @@ async def test_no_command_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_no_payload_close(
|
async def test_no_payload_close(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test with no close payload."""
|
"""Test with no close payload."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1228,7 +1234,7 @@ async def test_no_payload_close(
|
||||||
|
|
||||||
|
|
||||||
async def test_no_payload_open(
|
async def test_no_payload_open(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test with no open payload."""
|
"""Test with no open payload."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1254,7 +1260,7 @@ async def test_no_payload_open(
|
||||||
|
|
||||||
|
|
||||||
async def test_no_payload_stop(
|
async def test_no_payload_stop(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test with no stop payload."""
|
"""Test with no stop payload."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1280,7 +1286,7 @@ async def test_no_payload_stop(
|
||||||
|
|
||||||
|
|
||||||
async def test_with_command_topic_and_tilt(
|
async def test_with_command_topic_and_tilt(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test with command topic and tilt config."""
|
"""Test with command topic and tilt config."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1308,7 +1314,7 @@ async def test_with_command_topic_and_tilt(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_defaults(
|
async def test_tilt_defaults(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the defaults."""
|
"""Test the defaults."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1339,7 +1345,7 @@ async def test_tilt_defaults(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_via_invocation_defaults(
|
async def test_tilt_via_invocation_defaults(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tilt defaults on close/open."""
|
"""Test tilt defaults on close/open."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1425,7 +1431,7 @@ async def test_tilt_via_invocation_defaults(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_given_value(
|
async def test_tilt_given_value(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tilting to a given value."""
|
"""Test tilting to a given value."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1517,7 +1523,7 @@ async def test_tilt_given_value(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_given_value_optimistic(
|
async def test_tilt_given_value_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tilting to a given value."""
|
"""Test tilting to a given value."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1597,7 +1603,7 @@ async def test_tilt_given_value_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_given_value_altered_range(
|
async def test_tilt_given_value_altered_range(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tilting to a given value."""
|
"""Test tilting to a given value."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1677,7 +1683,7 @@ async def test_tilt_given_value_altered_range(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_via_topic(
|
async def test_tilt_via_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tilt by updating status via MQTT."""
|
"""Test tilt by updating status via MQTT."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1718,7 +1724,7 @@ async def test_tilt_via_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_via_topic_template(
|
async def test_tilt_via_topic_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tilt by updating status via MQTT and template."""
|
"""Test tilt by updating status via MQTT and template."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1762,7 +1768,9 @@ async def test_tilt_via_topic_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_via_topic_template_json_value(
|
async def test_tilt_via_topic_template_json_value(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tilt by updating status via MQTT and template with JSON value."""
|
"""Test tilt by updating status via MQTT and template with JSON value."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1812,7 +1820,7 @@ async def test_tilt_via_topic_template_json_value(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_via_topic_altered_range(
|
async def test_tilt_via_topic_altered_range(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tilt status via MQTT with altered tilt range."""
|
"""Test tilt status via MQTT with altered tilt range."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1862,7 +1870,9 @@ async def test_tilt_via_topic_altered_range(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_status_out_of_range_warning(
|
async def test_tilt_status_out_of_range_warning(
|
||||||
hass: HomeAssistant, caplog, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tilt status via MQTT tilt out of range warning message."""
|
"""Test tilt status via MQTT tilt out of range warning message."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1897,7 +1907,9 @@ async def test_tilt_status_out_of_range_warning(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_status_not_numeric_warning(
|
async def test_tilt_status_not_numeric_warning(
|
||||||
hass: HomeAssistant, caplog, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tilt status via MQTT tilt not numeric warning message."""
|
"""Test tilt status via MQTT tilt not numeric warning message."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1930,7 +1942,7 @@ async def test_tilt_status_not_numeric_warning(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_via_topic_altered_range_inverted(
|
async def test_tilt_via_topic_altered_range_inverted(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tilt status via MQTT with altered tilt range and inverted tilt position."""
|
"""Test tilt status via MQTT with altered tilt range and inverted tilt position."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1980,7 +1992,7 @@ async def test_tilt_via_topic_altered_range_inverted(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_via_topic_template_altered_range(
|
async def test_tilt_via_topic_template_altered_range(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tilt status via MQTT and template with altered tilt range."""
|
"""Test tilt status via MQTT and template with altered tilt range."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -2033,7 +2045,7 @@ async def test_tilt_via_topic_template_altered_range(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_position(
|
async def test_tilt_position(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tilt via method invocation."""
|
"""Test tilt via method invocation."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -2071,7 +2083,7 @@ async def test_tilt_position(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_position_templated(
|
async def test_tilt_position_templated(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tilt position via template."""
|
"""Test tilt position via template."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -2110,7 +2122,7 @@ async def test_tilt_position_templated(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_position_altered_range(
|
async def test_tilt_position_altered_range(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tilt via method invocation with altered range."""
|
"""Test tilt via method invocation with altered range."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -2496,7 +2508,7 @@ async def test_find_in_range_altered_inverted(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -2505,7 +2517,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -2514,7 +2526,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_payload(
|
await help_test_default_availability_payload(
|
||||||
|
@ -2523,7 +2535,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
await help_test_custom_availability_payload(
|
await help_test_custom_availability_payload(
|
||||||
|
@ -2532,7 +2544,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_valid_device_class(
|
async def test_valid_device_class(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of a valid device class."""
|
"""Test the setting of a valid device class."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -2574,7 +2586,7 @@ async def test_invalid_device_class(hass: HomeAssistant, caplog) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -2583,7 +2595,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -2596,7 +2608,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -2605,7 +2617,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -2618,7 +2632,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -2631,7 +2647,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -2667,7 +2685,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_cover(
|
async def test_discovery_removal_cover(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered cover."""
|
"""Test removal of discovered cover."""
|
||||||
data = '{ "name": "test", "command_topic": "test_topic" }'
|
data = '{ "name": "test", "command_topic": "test_topic" }'
|
||||||
|
@ -2677,7 +2697,9 @@ async def test_discovery_removal_cover(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_cover(
|
async def test_discovery_update_cover(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered cover."""
|
"""Test update of discovered cover."""
|
||||||
config1 = {"name": "Beer", "command_topic": "test_topic"}
|
config1 = {"name": "Beer", "command_topic": "test_topic"}
|
||||||
|
@ -2688,7 +2710,9 @@ async def test_discovery_update_cover(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_cover(
|
async def test_discovery_update_unchanged_cover(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered cover."""
|
"""Test update of discovered cover."""
|
||||||
data1 = '{ "name": "Beer", "command_topic": "test_topic" }'
|
data1 = '{ "name": "Beer", "command_topic": "test_topic" }'
|
||||||
|
@ -2707,7 +2731,9 @@ async def test_discovery_update_unchanged_cover(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer", "command_topic": "test_topic#" }'
|
data1 = '{ "name": "Beer", "command_topic": "test_topic#" }'
|
||||||
|
@ -2718,7 +2744,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT cover device registry integration."""
|
"""Test MQTT cover device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -2727,7 +2753,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT cover device registry integration."""
|
"""Test MQTT cover device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -2736,7 +2762,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -2745,7 +2771,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -2754,7 +2780,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
await help_test_entity_id_update_subscriptions(
|
await help_test_entity_id_update_subscriptions(
|
||||||
|
@ -2763,7 +2789,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -2772,7 +2798,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
await help_test_entity_debug_info_message(
|
await help_test_entity_debug_info_message(
|
||||||
|
@ -2786,7 +2812,7 @@ async def test_entity_debug_info_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_state_and_position_topics_state_not_set_via_position_topic(
|
async def test_state_and_position_topics_state_not_set_via_position_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test state is not set via position topic when both state and position topics are set."""
|
"""Test state is not set via position topic when both state and position topics are set."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -2847,7 +2873,7 @@ async def test_state_and_position_topics_state_not_set_via_position_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_set_state_via_position_using_stopped_state(
|
async def test_set_state_via_position_using_stopped_state(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via position topic using stopped state."""
|
"""Test the controlling state via position topic using stopped state."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -2904,7 +2930,7 @@ async def test_set_state_via_position_using_stopped_state(
|
||||||
|
|
||||||
|
|
||||||
async def test_position_via_position_topic_template(
|
async def test_position_via_position_topic_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test position by updating status via position template."""
|
"""Test position by updating status via position template."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -2942,7 +2968,9 @@ async def test_position_via_position_topic_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_position_via_position_topic_template_json_value(
|
async def test_position_via_position_topic_template_json_value(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test position by updating status via position template with a JSON value."""
|
"""Test position by updating status via position template with a JSON value."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -2986,7 +3014,7 @@ async def test_position_via_position_topic_template_json_value(
|
||||||
|
|
||||||
|
|
||||||
async def test_position_template_with_entity_id(
|
async def test_position_template_with_entity_id(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test position by updating status via position template."""
|
"""Test position by updating status via position template."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -3029,7 +3057,7 @@ async def test_position_template_with_entity_id(
|
||||||
|
|
||||||
|
|
||||||
async def test_position_via_position_topic_template_return_json(
|
async def test_position_via_position_topic_template_return_json(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test position by updating status via position template and returning json."""
|
"""Test position by updating status via position template and returning json."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -3060,7 +3088,9 @@ async def test_position_via_position_topic_template_return_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_position_via_position_topic_template_return_json_warning(
|
async def test_position_via_position_topic_template_return_json_warning(
|
||||||
hass: HomeAssistant, caplog, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test position by updating status via position template returning json without position attribute."""
|
"""Test position by updating status via position template returning json without position attribute."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -3091,7 +3121,7 @@ async def test_position_via_position_topic_template_return_json_warning(
|
||||||
|
|
||||||
|
|
||||||
async def test_position_and_tilt_via_position_topic_template_return_json(
|
async def test_position_and_tilt_via_position_topic_template_return_json(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test position and tilt by updating the position via position template."""
|
"""Test position and tilt by updating the position via position template."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -3135,7 +3165,7 @@ async def test_position_and_tilt_via_position_topic_template_return_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_position_via_position_topic_template_all_variables(
|
async def test_position_via_position_topic_template_all_variables(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test position by updating status via position template."""
|
"""Test position by updating status via position template."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -3183,7 +3213,7 @@ async def test_position_via_position_topic_template_all_variables(
|
||||||
|
|
||||||
|
|
||||||
async def test_set_state_via_stopped_state_no_position_topic(
|
async def test_set_state_via_stopped_state_no_position_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via stopped state when no position topic."""
|
"""Test the controlling state via stopped state when no position topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -3236,7 +3266,9 @@ async def test_set_state_via_stopped_state_no_position_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_position_via_position_topic_template_return_invalid_json(
|
async def test_position_via_position_topic_template_return_invalid_json(
|
||||||
hass: HomeAssistant, caplog, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test position by updating status via position template and returning invalid json."""
|
"""Test position by updating status via position template and returning invalid json."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -3288,7 +3320,7 @@ async def test_set_position_topic_without_get_position_topic_error(
|
||||||
|
|
||||||
async def test_value_template_without_state_topic_error(
|
async def test_value_template_without_state_topic_error(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test error when value_template is used and state_topic is missing."""
|
"""Test error when value_template is used and state_topic is missing."""
|
||||||
assert not await async_setup_component(
|
assert not await async_setup_component(
|
||||||
|
@ -3334,7 +3366,7 @@ async def test_position_template_without_position_topic_error(
|
||||||
|
|
||||||
async def test_set_position_template_without_set_position_topic(
|
async def test_set_position_template_without_set_position_topic(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test error when set_position_template is used and set_position_topic is missing."""
|
"""Test error when set_position_template is used and set_position_topic is missing."""
|
||||||
assert not await async_setup_component(
|
assert not await async_setup_component(
|
||||||
|
@ -3430,8 +3462,8 @@ async def test_tilt_status_template_without_tilt_status_topic_topic(
|
||||||
)
|
)
|
||||||
async def test_publishing_with_custom_encoding(
|
async def test_publishing_with_custom_encoding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
service,
|
service,
|
||||||
topic,
|
topic,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -3458,7 +3490,10 @@ async def test_publishing_with_custom_encoding(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = cover.DOMAIN
|
domain = cover.DOMAIN
|
||||||
|
@ -3479,8 +3514,8 @@ async def test_reloadable(
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
@ -3509,7 +3544,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = cover.DOMAIN
|
domain = cover.DOMAIN
|
||||||
|
|
|
@ -16,6 +16,7 @@ from .test_common import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message
|
from tests.common import async_fire_mqtt_message
|
||||||
|
from tests.typing import MqttMockHAClientGenerator, WebSocketGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
@ -35,7 +36,9 @@ def device_tracker_platform_only():
|
||||||
|
|
||||||
|
|
||||||
async def test_discover_device_tracker(
|
async def test_discover_device_tracker(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test discovering an MQTT device tracker component."""
|
"""Test discovering an MQTT device tracker component."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -55,7 +58,9 @@ async def test_discover_device_tracker(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -82,7 +87,9 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_non_duplicate_device_tracker_discovery(
|
async def test_non_duplicate_device_tracker_discovery(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for a non duplicate component."""
|
"""Test for a non duplicate component."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -108,7 +115,9 @@ async def test_non_duplicate_device_tracker_discovery(
|
||||||
|
|
||||||
|
|
||||||
async def test_device_tracker_removal(
|
async def test_device_tracker_removal(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of component through empty discovery message."""
|
"""Test removal of component through empty discovery message."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -128,7 +137,9 @@ async def test_device_tracker_removal(
|
||||||
|
|
||||||
|
|
||||||
async def test_device_tracker_rediscover(
|
async def test_device_tracker_rediscover(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test rediscover of removed component."""
|
"""Test rediscover of removed component."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -157,7 +168,9 @@ async def test_device_tracker_rediscover(
|
||||||
|
|
||||||
|
|
||||||
async def test_duplicate_device_tracker_removal(
|
async def test_duplicate_device_tracker_removal(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for a non duplicate component."""
|
"""Test for a non duplicate component."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -180,7 +193,9 @@ async def test_duplicate_device_tracker_removal(
|
||||||
|
|
||||||
|
|
||||||
async def test_device_tracker_discovery_update(
|
async def test_device_tracker_discovery_update(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for a discovery update event."""
|
"""Test for a discovery update event."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -209,10 +224,10 @@ async def test_device_tracker_discovery_update(
|
||||||
|
|
||||||
async def test_cleanup_device_tracker(
|
async def test_cleanup_device_tracker(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client,
|
hass_ws_client: WebSocketGenerator,
|
||||||
device_registry,
|
device_registry,
|
||||||
entity_registry,
|
entity_registry,
|
||||||
mqtt_mock_entry_no_yaml_config,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test discovered device is cleaned up when removed from registry."""
|
"""Test discovered device is cleaned up when removed from registry."""
|
||||||
assert await async_setup_component(hass, "config", {})
|
assert await async_setup_component(hass, "config", {})
|
||||||
|
@ -271,7 +286,9 @@ async def test_cleanup_device_tracker(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_device_tracker_value_via_mqtt_message(
|
async def test_setting_device_tracker_value_via_mqtt_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the value via MQTT."""
|
"""Test the setting of the value via MQTT."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -297,7 +314,9 @@ async def test_setting_device_tracker_value_via_mqtt_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_device_tracker_value_via_mqtt_message_and_template(
|
async def test_setting_device_tracker_value_via_mqtt_message_and_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the value via MQTT."""
|
"""Test the setting of the value via MQTT."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -322,7 +341,9 @@ async def test_setting_device_tracker_value_via_mqtt_message_and_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_device_tracker_value_via_mqtt_message_and_template2(
|
async def test_setting_device_tracker_value_via_mqtt_message_and_template2(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the value via MQTT."""
|
"""Test the setting of the value via MQTT."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -350,7 +371,9 @@ async def test_setting_device_tracker_value_via_mqtt_message_and_template2(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_device_tracker_location_via_mqtt_message(
|
async def test_setting_device_tracker_location_via_mqtt_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the location via MQTT."""
|
"""Test the setting of the location via MQTT."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -372,7 +395,9 @@ async def test_setting_device_tracker_location_via_mqtt_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_device_tracker_location_via_lat_lon_message(
|
async def test_setting_device_tracker_location_via_lat_lon_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the latitude and longitude via MQTT."""
|
"""Test the setting of the latitude and longitude via MQTT."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -431,7 +456,9 @@ async def test_setting_device_tracker_location_via_lat_lon_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_device_tracker_location_via_reset_message(
|
async def test_setting_device_tracker_location_via_reset_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the automatic inference of zones via MQTT via reset."""
|
"""Test the automatic inference of zones via MQTT via reset."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -505,7 +532,9 @@ async def test_setting_device_tracker_location_via_reset_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_device_tracker_location_via_abbr_reset_message(
|
async def test_setting_device_tracker_location_via_abbr_reset_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of reset via abbreviated names and custom payloads via MQTT."""
|
"""Test the setting of reset via abbreviated names and custom payloads via MQTT."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -547,7 +576,7 @@ async def test_setting_device_tracker_location_via_abbr_reset_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
|
@ -23,6 +23,7 @@ from tests.common import (
|
||||||
async_mock_service,
|
async_mock_service,
|
||||||
)
|
)
|
||||||
from tests.components.blueprint.conftest import stub_blueprint_populate # noqa: F401
|
from tests.components.blueprint.conftest import stub_blueprint_populate # noqa: F401
|
||||||
|
from tests.typing import MqttMockHAClient, MqttMockHAClientGenerator, WebSocketGenerator
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -42,7 +43,9 @@ def binary_sensor_and_sensor_only():
|
||||||
|
|
||||||
|
|
||||||
async def test_get_triggers(
|
async def test_get_triggers(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we get the expected triggers from a discovered mqtt device."""
|
"""Test we get the expected triggers from a discovered mqtt device."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -76,7 +79,9 @@ async def test_get_triggers(
|
||||||
|
|
||||||
|
|
||||||
async def test_get_unknown_triggers(
|
async def test_get_unknown_triggers(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we don't get unknown triggers."""
|
"""Test we don't get unknown triggers."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -121,7 +126,9 @@ async def test_get_unknown_triggers(
|
||||||
|
|
||||||
|
|
||||||
async def test_get_non_existing_triggers(
|
async def test_get_non_existing_triggers(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test getting non existing triggers."""
|
"""Test getting non existing triggers."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -143,7 +150,9 @@ async def test_get_non_existing_triggers(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discover_bad_triggers(
|
async def test_discover_bad_triggers(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test bad discovery message."""
|
"""Test bad discovery message."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -191,7 +200,9 @@ async def test_discover_bad_triggers(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_remove_triggers(
|
async def test_update_remove_triggers(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test triggers can be updated and removed."""
|
"""Test triggers can be updated and removed."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -258,7 +269,10 @@ async def test_update_remove_triggers(
|
||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_mqtt_message(
|
async def test_if_fires_on_mqtt_message(
|
||||||
hass: HomeAssistant, device_registry, calls, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
calls,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test triggers firing."""
|
"""Test triggers firing."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -334,7 +348,10 @@ async def test_if_fires_on_mqtt_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_mqtt_message_template(
|
async def test_if_fires_on_mqtt_message_template(
|
||||||
hass: HomeAssistant, device_registry, calls, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
calls,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test triggers firing."""
|
"""Test triggers firing."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -412,7 +429,10 @@ async def test_if_fires_on_mqtt_message_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_mqtt_message_late_discover(
|
async def test_if_fires_on_mqtt_message_late_discover(
|
||||||
hass: HomeAssistant, device_registry, calls, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
calls,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test triggers firing of MQTT device triggers discovered after setup."""
|
"""Test triggers firing of MQTT device triggers discovered after setup."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -496,7 +516,10 @@ async def test_if_fires_on_mqtt_message_late_discover(
|
||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_mqtt_message_after_update(
|
async def test_if_fires_on_mqtt_message_after_update(
|
||||||
hass: HomeAssistant, device_registry, calls, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
calls,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test triggers firing after update."""
|
"""Test triggers firing after update."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -573,7 +596,9 @@ async def test_if_fires_on_mqtt_message_after_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_no_resubscribe_same_topic(
|
async def test_no_resubscribe_same_topic(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test subscription to topics without change."""
|
"""Test subscription to topics without change."""
|
||||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -618,7 +643,10 @@ async def test_no_resubscribe_same_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_not_fires_on_mqtt_message_after_remove_by_mqtt(
|
async def test_not_fires_on_mqtt_message_after_remove_by_mqtt(
|
||||||
hass: HomeAssistant, device_registry, calls, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
calls,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test triggers not firing after removal."""
|
"""Test triggers not firing after removal."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -681,10 +709,10 @@ async def test_not_fires_on_mqtt_message_after_remove_by_mqtt(
|
||||||
|
|
||||||
async def test_not_fires_on_mqtt_message_after_remove_from_registry(
|
async def test_not_fires_on_mqtt_message_after_remove_from_registry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client,
|
hass_ws_client: WebSocketGenerator,
|
||||||
device_registry,
|
device_registry,
|
||||||
calls,
|
calls,
|
||||||
mqtt_mock_entry_no_yaml_config,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test triggers not firing after removal."""
|
"""Test triggers not firing after removal."""
|
||||||
assert await async_setup_component(hass, "config", {})
|
assert await async_setup_component(hass, "config", {})
|
||||||
|
@ -753,7 +781,9 @@ async def test_not_fires_on_mqtt_message_after_remove_from_registry(
|
||||||
|
|
||||||
|
|
||||||
async def test_attach_remove(
|
async def test_attach_remove(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attach and removal of trigger."""
|
"""Test attach and removal of trigger."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -809,7 +839,9 @@ async def test_attach_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_attach_remove_late(
|
async def test_attach_remove_late(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attach and removal of trigger ."""
|
"""Test attach and removal of trigger ."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -873,7 +905,9 @@ async def test_attach_remove_late(
|
||||||
|
|
||||||
|
|
||||||
async def test_attach_remove_late2(
|
async def test_attach_remove_late2(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attach and removal of trigger ."""
|
"""Test attach and removal of trigger ."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -931,7 +965,7 @@ async def test_attach_remove_late2(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT device registry integration."""
|
"""Test MQTT device registry integration."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -969,7 +1003,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT device registry integration."""
|
"""Test MQTT device registry integration."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -1005,7 +1039,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -1046,9 +1080,9 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
async def test_cleanup_trigger(
|
async def test_cleanup_trigger(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client,
|
hass_ws_client: WebSocketGenerator,
|
||||||
device_registry,
|
device_registry,
|
||||||
mqtt_mock_entry_no_yaml_config,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test trigger discovery topic is cleaned when device is removed from registry."""
|
"""Test trigger discovery topic is cleaned when device is removed from registry."""
|
||||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -1102,7 +1136,9 @@ async def test_cleanup_trigger(
|
||||||
|
|
||||||
|
|
||||||
async def test_cleanup_device(
|
async def test_cleanup_device(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal from device registry when trigger is removed."""
|
"""Test removal from device registry when trigger is removed."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -1136,7 +1172,9 @@ async def test_cleanup_device(
|
||||||
|
|
||||||
|
|
||||||
async def test_cleanup_device_several_triggers(
|
async def test_cleanup_device_several_triggers(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal from device registry when the last trigger is removed."""
|
"""Test removal from device registry when the last trigger is removed."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -1196,7 +1234,9 @@ async def test_cleanup_device_several_triggers(
|
||||||
|
|
||||||
|
|
||||||
async def test_cleanup_device_with_entity1(
|
async def test_cleanup_device_with_entity1(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal from device registry for device with entity.
|
"""Test removal from device registry for device with entity.
|
||||||
|
|
||||||
|
@ -1255,7 +1295,9 @@ async def test_cleanup_device_with_entity1(
|
||||||
|
|
||||||
|
|
||||||
async def test_cleanup_device_with_entity2(
|
async def test_cleanup_device_with_entity2(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal from device registry for device with entity.
|
"""Test removal from device registry for device with entity.
|
||||||
|
|
||||||
|
@ -1314,7 +1356,7 @@ async def test_cleanup_device_with_entity2(
|
||||||
|
|
||||||
|
|
||||||
async def test_trigger_debug_info(
|
async def test_trigger_debug_info(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test debug_info.
|
"""Test debug_info.
|
||||||
|
|
||||||
|
@ -1391,7 +1433,7 @@ async def test_trigger_debug_info(
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
async def test_unload_entry(
|
||||||
hass: HomeAssistant, calls, device_registry, mqtt_mock, tmp_path
|
hass: HomeAssistant, calls, device_registry, mqtt_mock: MqttMockHAClient, tmp_path
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test unloading the MQTT entry."""
|
"""Test unloading the MQTT entry."""
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ from tests.components.diagnostics import (
|
||||||
get_diagnostics_for_config_entry,
|
get_diagnostics_for_config_entry,
|
||||||
get_diagnostics_for_device,
|
get_diagnostics_for_device,
|
||||||
)
|
)
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
default_config = {
|
default_config = {
|
||||||
"birth_message": {},
|
"birth_message": {},
|
||||||
|
@ -53,7 +54,10 @@ def device_reg(hass: HomeAssistant):
|
||||||
|
|
||||||
|
|
||||||
async def test_entry_diagnostics(
|
async def test_entry_diagnostics(
|
||||||
hass: HomeAssistant, device_reg, hass_client, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_reg,
|
||||||
|
hass_client,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test config entry diagnostics."""
|
"""Test config entry diagnostics."""
|
||||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -173,7 +177,10 @@ async def test_entry_diagnostics(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_redact_diagnostics(
|
async def test_redact_diagnostics(
|
||||||
hass: HomeAssistant, device_reg, hass_client, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_reg,
|
||||||
|
hass_client,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test redacting diagnostics."""
|
"""Test redacting diagnostics."""
|
||||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""Test MQTT fans."""
|
"""Test MQTT fans."""
|
||||||
import copy
|
import copy
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -65,6 +66,7 @@ from .test_common import (
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message
|
from tests.common import async_fire_mqtt_message
|
||||||
from tests.components.fan import common
|
from tests.components.fan import common
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
@ -98,7 +100,9 @@ async def test_fail_setup_if_no_command_topic(hass: HomeAssistant, caplog) -> No
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_via_topic(
|
async def test_controlling_state_via_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic."""
|
"""Test the controlling state via topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -220,7 +224,9 @@ async def test_controlling_state_via_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_via_topic_with_different_speed_range(
|
async def test_controlling_state_via_topic_with_different_speed_range(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic using an alternate speed range."""
|
"""Test the controlling state via topic using an alternate speed range."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -282,7 +288,9 @@ async def test_controlling_state_via_topic_with_different_speed_range(
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_via_topic_no_percentage_topics(
|
async def test_controlling_state_via_topic_no_percentage_topics(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic without percentage topics."""
|
"""Test the controlling state via topic without percentage topics."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -339,7 +347,9 @@ async def test_controlling_state_via_topic_no_percentage_topics(
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_via_topic_and_json_message(
|
async def test_controlling_state_via_topic_and_json_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic and JSON message (percentage mode)."""
|
"""Test the controlling state via topic and JSON message (percentage mode)."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -444,7 +454,9 @@ async def test_controlling_state_via_topic_and_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_via_topic_and_json_message_shared_topic(
|
async def test_controlling_state_via_topic_and_json_message_shared_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic and JSON message using a shared topic."""
|
"""Test the controlling state via topic and JSON message using a shared topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -532,7 +544,9 @@ async def test_controlling_state_via_topic_and_json_message_shared_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_and_optimistic(
|
async def test_sending_mqtt_commands_and_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test optimistic mode without state topic."""
|
"""Test optimistic mode without state topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -657,7 +671,7 @@ async def test_sending_mqtt_commands_and_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_with_alternate_speed_range(
|
async def test_sending_mqtt_commands_with_alternate_speed_range(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic using an alternate speed range."""
|
"""Test the controlling state via topic using an alternate speed range."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -763,7 +777,9 @@ async def test_sending_mqtt_commands_with_alternate_speed_range(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_and_optimistic_no_legacy(
|
async def test_sending_mqtt_commands_and_optimistic_no_legacy(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test optimistic mode without state topic without legacy speed command topic."""
|
"""Test optimistic mode without state topic without legacy speed command topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -895,7 +911,9 @@ async def test_sending_mqtt_commands_and_optimistic_no_legacy(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_command_templates_(
|
async def test_sending_mqtt_command_templates_(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test optimistic mode without state topic without legacy speed command topic."""
|
"""Test optimistic mode without state topic without legacy speed command topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1038,7 +1056,9 @@ async def test_sending_mqtt_command_templates_(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_and_optimistic_no_percentage_topic(
|
async def test_sending_mqtt_commands_and_optimistic_no_percentage_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test optimistic mode without state topic without percentage command topic."""
|
"""Test optimistic mode without state topic without percentage command topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1100,7 +1120,9 @@ async def test_sending_mqtt_commands_and_optimistic_no_percentage_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_and_explicit_optimistic(
|
async def test_sending_mqtt_commands_and_explicit_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test optimistic mode with state topic and turn on attributes."""
|
"""Test optimistic mode with state topic and turn on attributes."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1348,8 +1370,8 @@ async def test_sending_mqtt_commands_and_explicit_optimistic(
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
@ -1375,7 +1397,9 @@ async def test_encoding_subscribable_topics(
|
||||||
|
|
||||||
|
|
||||||
async def test_attributes(
|
async def test_attributes(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attributes."""
|
"""Test attributes."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1610,7 +1634,7 @@ async def test_attributes(
|
||||||
)
|
)
|
||||||
async def test_supported_features(
|
async def test_supported_features(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
name,
|
name,
|
||||||
config,
|
config,
|
||||||
success,
|
success,
|
||||||
|
@ -1633,7 +1657,7 @@ async def test_supported_features(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -1642,7 +1666,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -1651,7 +1675,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_payload(
|
await help_test_default_availability_payload(
|
||||||
|
@ -1666,7 +1690,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
await help_test_custom_availability_payload(
|
await help_test_custom_availability_payload(
|
||||||
|
@ -1681,7 +1705,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -1690,7 +1714,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -1703,7 +1727,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -1712,7 +1736,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -1725,7 +1751,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -1738,7 +1766,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -1772,7 +1802,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_fan(
|
async def test_discovery_removal_fan(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered fan."""
|
"""Test removal of discovered fan."""
|
||||||
data = '{ "name": "test", "command_topic": "test_topic" }'
|
data = '{ "name": "test", "command_topic": "test_topic" }'
|
||||||
|
@ -1782,7 +1814,9 @@ async def test_discovery_removal_fan(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_fan(
|
async def test_discovery_update_fan(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered fan."""
|
"""Test update of discovered fan."""
|
||||||
config1 = {"name": "Beer", "command_topic": "test_topic"}
|
config1 = {"name": "Beer", "command_topic": "test_topic"}
|
||||||
|
@ -1793,7 +1827,9 @@ async def test_discovery_update_fan(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_fan(
|
async def test_discovery_update_unchanged_fan(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered fan."""
|
"""Test update of discovered fan."""
|
||||||
data1 = '{ "name": "Beer", "command_topic": "test_topic" }'
|
data1 = '{ "name": "Beer", "command_topic": "test_topic" }'
|
||||||
|
@ -1812,7 +1848,9 @@ async def test_discovery_update_unchanged_fan(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer" }'
|
data1 = '{ "name": "Beer" }'
|
||||||
|
@ -1824,7 +1862,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT fan device registry integration."""
|
"""Test MQTT fan device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -1833,7 +1871,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT fan device registry integration."""
|
"""Test MQTT fan device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -1842,7 +1880,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -1851,7 +1889,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -1860,7 +1898,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
await help_test_entity_id_update_subscriptions(
|
await help_test_entity_id_update_subscriptions(
|
||||||
|
@ -1869,7 +1907,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -1878,7 +1916,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
await help_test_entity_debug_info_message(
|
await help_test_entity_debug_info_message(
|
||||||
|
@ -1932,8 +1970,8 @@ async def test_entity_debug_info_message(
|
||||||
)
|
)
|
||||||
async def test_publishing_with_custom_encoding(
|
async def test_publishing_with_custom_encoding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
service,
|
service,
|
||||||
topic,
|
topic,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -1961,7 +1999,10 @@ async def test_publishing_with_custom_encoding(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = fan.DOMAIN
|
domain = fan.DOMAIN
|
||||||
|
@ -1979,7 +2020,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = fan.DOMAIN
|
domain = fan.DOMAIN
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""Test MQTT humidifiers."""
|
"""Test MQTT humidifiers."""
|
||||||
import copy
|
import copy
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -66,6 +67,7 @@ from .test_common import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message
|
from tests.common import async_fire_mqtt_message
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
@ -143,7 +145,9 @@ async def test_fail_setup_if_no_command_topic(hass: HomeAssistant, caplog) -> No
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_via_topic(
|
async def test_controlling_state_via_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic."""
|
"""Test the controlling state via topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -248,7 +252,9 @@ async def test_controlling_state_via_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_via_topic_and_json_message(
|
async def test_controlling_state_via_topic_and_json_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic and JSON message."""
|
"""Test the controlling state via topic and JSON message."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -337,7 +343,9 @@ async def test_controlling_state_via_topic_and_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_via_topic_and_json_message_shared_topic(
|
async def test_controlling_state_via_topic_and_json_message_shared_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic and JSON message using a shared topic."""
|
"""Test the controlling state via topic and JSON message using a shared topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -414,7 +422,9 @@ async def test_controlling_state_via_topic_and_json_message_shared_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_and_optimistic(
|
async def test_sending_mqtt_commands_and_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test optimistic mode without state topic."""
|
"""Test optimistic mode without state topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -511,7 +521,9 @@ async def test_sending_mqtt_commands_and_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_command_templates_(
|
async def test_sending_mqtt_command_templates_(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Testing command templates with optimistic mode without state topic."""
|
"""Testing command templates with optimistic mode without state topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -609,7 +621,9 @@ async def test_sending_mqtt_command_templates_(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_and_explicit_optimistic(
|
async def test_sending_mqtt_commands_and_explicit_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test optimistic mode with state topic and turn on attributes."""
|
"""Test optimistic mode with state topic and turn on attributes."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -737,8 +751,8 @@ async def test_sending_mqtt_commands_and_explicit_optimistic(
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
@ -762,7 +776,9 @@ async def test_encoding_subscribable_topics(
|
||||||
|
|
||||||
|
|
||||||
async def test_attributes(
|
async def test_attributes(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attributes."""
|
"""Test attributes."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -970,7 +986,7 @@ async def test_validity_configurations(hass: HomeAssistant, config, valid) -> No
|
||||||
)
|
)
|
||||||
async def test_supported_features(
|
async def test_supported_features(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
name,
|
name,
|
||||||
config,
|
config,
|
||||||
success,
|
success,
|
||||||
|
@ -994,7 +1010,7 @@ async def test_supported_features(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -1003,7 +1019,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -1012,7 +1028,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_payload(
|
await help_test_default_availability_payload(
|
||||||
|
@ -1027,7 +1043,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
await help_test_custom_availability_payload(
|
await help_test_custom_availability_payload(
|
||||||
|
@ -1042,7 +1058,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -1051,7 +1067,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -1064,7 +1080,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -1073,7 +1089,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -1086,7 +1104,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -1099,7 +1119,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -1139,7 +1161,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_humidifier(
|
async def test_discovery_removal_humidifier(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered humidifier."""
|
"""Test removal of discovered humidifier."""
|
||||||
data = '{ "name": "test", "command_topic": "test_topic", "target_humidity_command_topic": "test-topic2" }'
|
data = '{ "name": "test", "command_topic": "test_topic", "target_humidity_command_topic": "test-topic2" }'
|
||||||
|
@ -1149,7 +1173,9 @@ async def test_discovery_removal_humidifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_humidifier(
|
async def test_discovery_update_humidifier(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered humidifier."""
|
"""Test update of discovered humidifier."""
|
||||||
config1 = {
|
config1 = {
|
||||||
|
@ -1173,7 +1199,9 @@ async def test_discovery_update_humidifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_humidifier(
|
async def test_discovery_update_unchanged_humidifier(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered humidifier."""
|
"""Test update of discovered humidifier."""
|
||||||
data1 = '{ "name": "Beer", "command_topic": "test_topic", "target_humidity_command_topic": "test-topic2" }'
|
data1 = '{ "name": "Beer", "command_topic": "test_topic", "target_humidity_command_topic": "test-topic2" }'
|
||||||
|
@ -1192,7 +1220,9 @@ async def test_discovery_update_unchanged_humidifier(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer" }'
|
data1 = '{ "name": "Beer" }'
|
||||||
|
@ -1203,7 +1233,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT fan device registry integration."""
|
"""Test MQTT fan device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -1212,7 +1242,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT fan device registry integration."""
|
"""Test MQTT fan device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -1221,7 +1251,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -1230,7 +1260,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -1239,7 +1269,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
await help_test_entity_id_update_subscriptions(
|
await help_test_entity_id_update_subscriptions(
|
||||||
|
@ -1248,7 +1278,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -1257,7 +1287,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
await help_test_entity_debug_info_message(
|
await help_test_entity_debug_info_message(
|
||||||
|
@ -1304,8 +1334,8 @@ async def test_entity_debug_info_message(
|
||||||
)
|
)
|
||||||
async def test_publishing_with_custom_encoding(
|
async def test_publishing_with_custom_encoding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
service,
|
service,
|
||||||
topic,
|
topic,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -1333,7 +1363,10 @@ async def test_publishing_with_custom_encoding(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = humidifier.DOMAIN
|
domain = humidifier.DOMAIN
|
||||||
|
@ -1362,7 +1395,9 @@ async def test_config_schema_validation(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_config_entry(
|
async def test_unload_config_entry(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, tmp_path
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
tmp_path: Path,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = humidifier.DOMAIN
|
domain = humidifier.DOMAIN
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""The tests for the Legacy Mqtt vacuum platform."""
|
"""The tests for the Legacy Mqtt vacuum platform."""
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import json
|
import json
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -64,6 +65,7 @@ from .test_common import (
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message
|
from tests.common import async_fire_mqtt_message
|
||||||
from tests.components.vacuum import common
|
from tests.components.vacuum import common
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
@ -100,7 +102,7 @@ def vacuum_platform_only():
|
||||||
|
|
||||||
|
|
||||||
async def test_default_supported_features(
|
async def test_default_supported_features(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that the correct supported features."""
|
"""Test that the correct supported features."""
|
||||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
||||||
|
@ -122,7 +124,7 @@ async def test_default_supported_features(
|
||||||
|
|
||||||
|
|
||||||
async def test_all_commands(
|
async def test_all_commands(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test simple commands to the vacuum."""
|
"""Test simple commands to the vacuum."""
|
||||||
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
||||||
|
@ -206,7 +208,7 @@ async def test_all_commands(
|
||||||
|
|
||||||
|
|
||||||
async def test_commands_without_supported_features(
|
async def test_commands_without_supported_features(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test commands which are not supported by the vacuum."""
|
"""Test commands which are not supported by the vacuum."""
|
||||||
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
||||||
|
@ -259,7 +261,7 @@ async def test_commands_without_supported_features(
|
||||||
|
|
||||||
|
|
||||||
async def test_attributes_without_supported_features(
|
async def test_attributes_without_supported_features(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attributes which are not supported by the vacuum."""
|
"""Test attributes which are not supported by the vacuum."""
|
||||||
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
||||||
|
@ -334,7 +336,7 @@ async def test_status(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) ->
|
||||||
|
|
||||||
|
|
||||||
async def test_status_battery(
|
async def test_status_battery(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test status updates from the vacuum."""
|
"""Test status updates from the vacuum."""
|
||||||
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
||||||
|
@ -357,7 +359,7 @@ async def test_status_battery(
|
||||||
|
|
||||||
|
|
||||||
async def test_status_cleaning(
|
async def test_status_cleaning(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test status updates from the vacuum."""
|
"""Test status updates from the vacuum."""
|
||||||
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
||||||
|
@ -380,7 +382,7 @@ async def test_status_cleaning(
|
||||||
|
|
||||||
|
|
||||||
async def test_status_docked(
|
async def test_status_docked(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test status updates from the vacuum."""
|
"""Test status updates from the vacuum."""
|
||||||
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
||||||
|
@ -403,7 +405,7 @@ async def test_status_docked(
|
||||||
|
|
||||||
|
|
||||||
async def test_status_charging(
|
async def test_status_charging(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test status updates from the vacuum."""
|
"""Test status updates from the vacuum."""
|
||||||
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
||||||
|
@ -426,7 +428,7 @@ async def test_status_charging(
|
||||||
|
|
||||||
|
|
||||||
async def test_status_fan_speed(
|
async def test_status_fan_speed(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test status updates from the vacuum."""
|
"""Test status updates from the vacuum."""
|
||||||
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
||||||
|
@ -449,7 +451,7 @@ async def test_status_fan_speed(
|
||||||
|
|
||||||
|
|
||||||
async def test_status_fan_speed_list(
|
async def test_status_fan_speed_list(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test status updates from the vacuum."""
|
"""Test status updates from the vacuum."""
|
||||||
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
||||||
|
@ -468,7 +470,7 @@ async def test_status_fan_speed_list(
|
||||||
|
|
||||||
|
|
||||||
async def test_status_no_fan_speed_list(
|
async def test_status_no_fan_speed_list(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test status updates from the vacuum.
|
"""Test status updates from the vacuum.
|
||||||
|
|
||||||
|
@ -491,7 +493,7 @@ async def test_status_no_fan_speed_list(
|
||||||
|
|
||||||
|
|
||||||
async def test_status_error(
|
async def test_status_error(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test status updates from the vacuum."""
|
"""Test status updates from the vacuum."""
|
||||||
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
||||||
|
@ -521,7 +523,7 @@ async def test_status_error(
|
||||||
|
|
||||||
|
|
||||||
async def test_battery_template(
|
async def test_battery_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that you can use non-default templates for battery_level."""
|
"""Test that you can use non-default templates for battery_level."""
|
||||||
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
||||||
|
@ -548,7 +550,7 @@ async def test_battery_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_status_invalid_json(
|
async def test_status_invalid_json(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test to make sure nothing breaks if the vacuum sends bad JSON."""
|
"""Test to make sure nothing breaks if the vacuum sends bad JSON."""
|
||||||
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
||||||
|
@ -629,7 +631,7 @@ async def test_missing_fan_speed_template(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -638,7 +640,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -647,7 +649,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_payload(
|
await help_test_default_availability_payload(
|
||||||
|
@ -656,7 +658,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
await help_test_custom_availability_payload(
|
await help_test_custom_availability_payload(
|
||||||
|
@ -665,7 +667,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -674,7 +676,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -687,7 +689,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -696,7 +698,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -709,7 +713,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -722,7 +728,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -758,7 +766,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_vacuum(
|
async def test_discovery_removal_vacuum(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered vacuum."""
|
"""Test removal of discovered vacuum."""
|
||||||
data = json.dumps(DEFAULT_CONFIG_2[mqtt.DOMAIN][vacuum.DOMAIN])
|
data = json.dumps(DEFAULT_CONFIG_2[mqtt.DOMAIN][vacuum.DOMAIN])
|
||||||
|
@ -768,7 +778,9 @@ async def test_discovery_removal_vacuum(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_vacuum(
|
async def test_discovery_update_vacuum(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered vacuum."""
|
"""Test update of discovered vacuum."""
|
||||||
config1 = {"name": "Beer", "command_topic": "test_topic"}
|
config1 = {"name": "Beer", "command_topic": "test_topic"}
|
||||||
|
@ -779,7 +791,9 @@ async def test_discovery_update_vacuum(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_vacuum(
|
async def test_discovery_update_unchanged_vacuum(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered vacuum."""
|
"""Test update of discovered vacuum."""
|
||||||
data1 = '{ "name": "Beer", "command_topic": "test_topic" }'
|
data1 = '{ "name": "Beer", "command_topic": "test_topic" }'
|
||||||
|
@ -798,7 +812,9 @@ async def test_discovery_update_unchanged_vacuum(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer",' ' "command_topic": "test_topic#" }'
|
data1 = '{ "name": "Beer",' ' "command_topic": "test_topic#" }'
|
||||||
|
@ -809,7 +825,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT vacuum device registry integration."""
|
"""Test MQTT vacuum device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -818,7 +834,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT vacuum device registry integration."""
|
"""Test MQTT vacuum device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -827,7 +843,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -836,7 +852,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -845,7 +861,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -869,7 +885,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -878,7 +894,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -943,8 +959,8 @@ async def test_entity_debug_info_message(
|
||||||
)
|
)
|
||||||
async def test_publishing_with_custom_encoding(
|
async def test_publishing_with_custom_encoding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
service,
|
service,
|
||||||
topic,
|
topic,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -977,7 +993,10 @@ async def test_publishing_with_custom_encoding(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = vacuum.DOMAIN
|
domain = vacuum.DOMAIN
|
||||||
|
@ -1010,8 +1029,8 @@ async def test_reloadable(
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
|
|
@ -169,6 +169,7 @@ mqtt:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import copy
|
import copy
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import call, patch
|
from unittest.mock import call, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -228,6 +229,7 @@ from .test_common import (
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message, mock_restore_cache
|
from tests.common import async_fire_mqtt_message, mock_restore_cache
|
||||||
from tests.components.light import common
|
from tests.components.light import common
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {light.DOMAIN: {"name": "test", "command_topic": "test-topic"}}
|
mqtt.DOMAIN: {light.DOMAIN: {"name": "test", "command_topic": "test-topic"}}
|
||||||
|
@ -253,7 +255,7 @@ async def test_fail_setup_if_no_command_topic(hass: HomeAssistant, caplog) -> No
|
||||||
|
|
||||||
|
|
||||||
async def test_no_color_brightness_color_temp_hs_white_xy_if_no_topics(
|
async def test_no_color_brightness_color_temp_hs_white_xy_if_no_topics(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test if there is no color and brightness if no topic."""
|
"""Test if there is no color and brightness if no topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -312,7 +314,7 @@ async def test_no_color_brightness_color_temp_hs_white_xy_if_no_topics(
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_via_topic(
|
async def test_controlling_state_via_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling of the state via topic."""
|
"""Test the controlling of the state via topic."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -433,7 +435,9 @@ async def test_controlling_state_via_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_invalid_state_via_topic(
|
async def test_invalid_state_via_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test handling of empty data via topic."""
|
"""Test handling of empty data via topic."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -559,7 +563,7 @@ async def test_invalid_state_via_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_brightness_controlling_scale(
|
async def test_brightness_controlling_scale(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the brightness controlling scale."""
|
"""Test the brightness controlling scale."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -609,7 +613,7 @@ async def test_brightness_controlling_scale(
|
||||||
|
|
||||||
|
|
||||||
async def test_brightness_from_rgb_controlling_scale(
|
async def test_brightness_from_rgb_controlling_scale(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the brightness controlling scale."""
|
"""Test the brightness controlling scale."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -651,7 +655,7 @@ async def test_brightness_from_rgb_controlling_scale(
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_via_topic_with_templates(
|
async def test_controlling_state_via_topic_with_templates(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the state with a template."""
|
"""Test the setting of the state with a template."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -753,7 +757,7 @@ async def test_controlling_state_via_topic_with_templates(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_and_optimistic(
|
async def test_sending_mqtt_commands_and_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending of command in optimistic mode."""
|
"""Test the sending of command in optimistic mode."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -942,7 +946,7 @@ async def test_sending_mqtt_commands_and_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_rgb_command_with_template(
|
async def test_sending_mqtt_rgb_command_with_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending of RGB command with template."""
|
"""Test the sending of RGB command with template."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -981,7 +985,7 @@ async def test_sending_mqtt_rgb_command_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_rgbw_command_with_template(
|
async def test_sending_mqtt_rgbw_command_with_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending of RGBW command with template."""
|
"""Test the sending of RGBW command with template."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1020,7 +1024,7 @@ async def test_sending_mqtt_rgbw_command_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_rgbww_command_with_template(
|
async def test_sending_mqtt_rgbww_command_with_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending of RGBWW command with template."""
|
"""Test the sending of RGBWW command with template."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1059,7 +1063,7 @@ async def test_sending_mqtt_rgbww_command_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_color_temp_command_with_template(
|
async def test_sending_mqtt_color_temp_command_with_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending of Color Temp command with template."""
|
"""Test the sending of Color Temp command with template."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1097,7 +1101,7 @@ async def test_sending_mqtt_color_temp_command_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_on_command_first(
|
async def test_on_command_first(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test on command being sent before brightness."""
|
"""Test on command being sent before brightness."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1135,7 +1139,7 @@ async def test_on_command_first(
|
||||||
|
|
||||||
|
|
||||||
async def test_on_command_last(
|
async def test_on_command_last(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test on command being sent after brightness."""
|
"""Test on command being sent after brightness."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1172,7 +1176,7 @@ async def test_on_command_last(
|
||||||
|
|
||||||
|
|
||||||
async def test_on_command_brightness(
|
async def test_on_command_brightness(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test on command being sent as only brightness."""
|
"""Test on command being sent as only brightness."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1229,7 +1233,7 @@ async def test_on_command_brightness(
|
||||||
|
|
||||||
|
|
||||||
async def test_on_command_brightness_scaled(
|
async def test_on_command_brightness_scaled(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test brightness scale."""
|
"""Test brightness scale."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1301,7 +1305,7 @@ async def test_on_command_brightness_scaled(
|
||||||
|
|
||||||
|
|
||||||
async def test_on_command_rgb(
|
async def test_on_command_rgb(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test on command in RGB brightness mode."""
|
"""Test on command in RGB brightness mode."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1393,7 +1397,7 @@ async def test_on_command_rgb(
|
||||||
|
|
||||||
|
|
||||||
async def test_on_command_rgbw(
|
async def test_on_command_rgbw(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test on command in RGBW brightness mode."""
|
"""Test on command in RGBW brightness mode."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1485,7 +1489,7 @@ async def test_on_command_rgbw(
|
||||||
|
|
||||||
|
|
||||||
async def test_on_command_rgbww(
|
async def test_on_command_rgbww(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test on command in RGBWW brightness mode."""
|
"""Test on command in RGBWW brightness mode."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1577,7 +1581,7 @@ async def test_on_command_rgbww(
|
||||||
|
|
||||||
|
|
||||||
async def test_on_command_rgb_template(
|
async def test_on_command_rgb_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test on command in RGB brightness mode with RGB template."""
|
"""Test on command in RGB brightness mode with RGB template."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1616,7 +1620,7 @@ async def test_on_command_rgb_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_on_command_rgbw_template(
|
async def test_on_command_rgbw_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test on command in RGBW brightness mode with RGBW template."""
|
"""Test on command in RGBW brightness mode with RGBW template."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1654,7 +1658,7 @@ async def test_on_command_rgbw_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_on_command_rgbww_template(
|
async def test_on_command_rgbww_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test on command in RGBWW brightness mode with RGBWW template."""
|
"""Test on command in RGBWW brightness mode with RGBWW template."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1693,7 +1697,7 @@ async def test_on_command_rgbww_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_on_command_white(
|
async def test_on_command_white(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test sending commands for RGB + white light."""
|
"""Test sending commands for RGB + white light."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1772,7 +1776,7 @@ async def test_on_command_white(
|
||||||
|
|
||||||
|
|
||||||
async def test_explicit_color_mode(
|
async def test_explicit_color_mode(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test explicit color mode over mqtt."""
|
"""Test explicit color mode over mqtt."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1922,7 +1926,7 @@ async def test_explicit_color_mode(
|
||||||
|
|
||||||
|
|
||||||
async def test_explicit_color_mode_templated(
|
async def test_explicit_color_mode_templated(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test templated explicit color mode over mqtt."""
|
"""Test templated explicit color mode over mqtt."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -2005,7 +2009,7 @@ async def test_explicit_color_mode_templated(
|
||||||
|
|
||||||
|
|
||||||
async def test_white_state_update(
|
async def test_white_state_update(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test state updates for RGB + white light."""
|
"""Test state updates for RGB + white light."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -2108,7 +2112,7 @@ async def test_effect(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) ->
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -2117,7 +2121,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -2126,7 +2130,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_payload(
|
await help_test_default_availability_payload(
|
||||||
|
@ -2135,7 +2139,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
await help_test_custom_availability_payload(
|
await help_test_custom_availability_payload(
|
||||||
|
@ -2144,7 +2148,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -2153,7 +2157,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -2166,7 +2170,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -2175,7 +2179,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -2188,7 +2194,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -2201,7 +2209,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -2239,7 +2249,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_light(
|
async def test_discovery_removal_light(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered light."""
|
"""Test removal of discovered light."""
|
||||||
data = (
|
data = (
|
||||||
|
@ -2253,7 +2265,9 @@ async def test_discovery_removal_light(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_ignores_extra_keys(
|
async def test_discovery_ignores_extra_keys(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test discovery ignores extra keys that are not blocked."""
|
"""Test discovery ignores extra keys that are not blocked."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -2269,7 +2283,9 @@ async def test_discovery_ignores_extra_keys(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_light_topic_and_template(
|
async def test_discovery_update_light_topic_and_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered light."""
|
"""Test update of discovered light."""
|
||||||
config1 = {
|
config1 = {
|
||||||
|
@ -2524,7 +2540,9 @@ async def test_discovery_update_light_topic_and_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_light_template(
|
async def test_discovery_update_light_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered light."""
|
"""Test update of discovered light."""
|
||||||
config1 = {
|
config1 = {
|
||||||
|
@ -2737,7 +2755,9 @@ async def test_discovery_update_light_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_light(
|
async def test_discovery_update_unchanged_light(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered light."""
|
"""Test update of discovered light."""
|
||||||
data1 = (
|
data1 = (
|
||||||
|
@ -2760,7 +2780,9 @@ async def test_discovery_update_unchanged_light(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer" }'
|
data1 = '{ "name": "Beer" }'
|
||||||
|
@ -2775,7 +2797,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT light device registry integration."""
|
"""Test MQTT light device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -2784,7 +2806,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT light device registry integration."""
|
"""Test MQTT light device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -2793,7 +2815,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -2802,7 +2824,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -2811,7 +2833,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
await help_test_entity_id_update_subscriptions(
|
await help_test_entity_id_update_subscriptions(
|
||||||
|
@ -2820,7 +2842,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -2829,7 +2851,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
await help_test_entity_debug_info_message(
|
await help_test_entity_debug_info_message(
|
||||||
|
@ -2842,7 +2864,7 @@ async def test_entity_debug_info_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_max_mireds(
|
async def test_max_mireds(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting min_mireds and max_mireds."""
|
"""Test setting min_mireds and max_mireds."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -2951,8 +2973,8 @@ async def test_max_mireds(
|
||||||
)
|
)
|
||||||
async def test_publishing_with_custom_encoding(
|
async def test_publishing_with_custom_encoding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
service,
|
service,
|
||||||
topic,
|
topic,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -2986,7 +3008,10 @@ async def test_publishing_with_custom_encoding(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = light.DOMAIN
|
domain = light.DOMAIN
|
||||||
|
@ -3028,8 +3053,8 @@ async def test_reloadable(
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
@ -3071,8 +3096,8 @@ async def test_encoding_subscribable_topics(
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics_brightness(
|
async def test_encoding_subscribable_topics_brightness(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
@ -3098,7 +3123,7 @@ async def test_encoding_subscribable_topics_brightness(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_brightness_command_with_template(
|
async def test_sending_mqtt_brightness_command_with_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending of Brightness command with template."""
|
"""Test the sending of Brightness command with template."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -3136,7 +3161,7 @@ async def test_sending_mqtt_brightness_command_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_effect_command_with_template(
|
async def test_sending_mqtt_effect_command_with_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending of Effect command with template."""
|
"""Test the sending of Effect command with template."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -3180,7 +3205,7 @@ async def test_sending_mqtt_effect_command_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_hs_command_with_template(
|
async def test_sending_mqtt_hs_command_with_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending of HS Color command with template."""
|
"""Test the sending of HS Color command with template."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -3216,7 +3241,7 @@ async def test_sending_mqtt_hs_command_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_xy_command_with_template(
|
async def test_sending_mqtt_xy_command_with_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending of XY Color command with template."""
|
"""Test the sending of XY Color command with template."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -3259,7 +3284,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = light.DOMAIN
|
domain = light.DOMAIN
|
||||||
|
|
|
@ -80,6 +80,7 @@ light:
|
||||||
"""
|
"""
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import call, patch
|
from unittest.mock import call, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -130,6 +131,7 @@ from .test_common import (
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message, mock_restore_cache
|
from tests.common import async_fire_mqtt_message, mock_restore_cache
|
||||||
from tests.components.light import common
|
from tests.components.light import common
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
@ -176,7 +178,7 @@ async def test_fail_setup_if_no_command_topic(hass: HomeAssistant, caplog) -> No
|
||||||
|
|
||||||
@pytest.mark.parametrize("deprecated", ("color_temp", "hs", "rgb", "xy"))
|
@pytest.mark.parametrize("deprecated", ("color_temp", "hs", "rgb", "xy"))
|
||||||
async def test_fail_setup_if_color_mode_deprecated(
|
async def test_fail_setup_if_color_mode_deprecated(
|
||||||
hass: HomeAssistant, caplog, deprecated
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, deprecated
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test if setup fails if color mode is combined with deprecated config keys."""
|
"""Test if setup fails if color mode is combined with deprecated config keys."""
|
||||||
supported_color_modes = ["color_temp", "hs", "rgb", "rgbw", "rgbww", "xy"]
|
supported_color_modes = ["color_temp", "hs", "rgb", "rgbw", "rgbww", "xy"]
|
||||||
|
@ -212,7 +214,7 @@ async def test_fail_setup_if_color_mode_deprecated(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_fail_setup_if_color_modes_invalid(
|
async def test_fail_setup_if_color_modes_invalid(
|
||||||
hass: HomeAssistant, caplog, supported_color_modes, error
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, supported_color_modes, error
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test if setup fails if supported color modes is invalid."""
|
"""Test if setup fails if supported color modes is invalid."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -234,7 +236,7 @@ async def test_fail_setup_if_color_modes_invalid(
|
||||||
|
|
||||||
|
|
||||||
async def test_legacy_rgb_light(
|
async def test_legacy_rgb_light(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test legacy RGB light flags expected features and color modes."""
|
"""Test legacy RGB light flags expected features and color modes."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -262,7 +264,7 @@ async def test_legacy_rgb_light(
|
||||||
|
|
||||||
|
|
||||||
async def test_no_color_brightness_color_temp_if_no_topics(
|
async def test_no_color_brightness_color_temp_if_no_topics(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for no RGB, brightness, color temp, effector XY."""
|
"""Test for no RGB, brightness, color temp, effector XY."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -316,7 +318,7 @@ async def test_no_color_brightness_color_temp_if_no_topics(
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_via_topic(
|
async def test_controlling_state_via_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling of the state via topic."""
|
"""Test the controlling of the state via topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -460,7 +462,9 @@ async def test_controlling_state_via_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_via_topic2(
|
async def test_controlling_state_via_topic2(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling of the state via topic for a light supporting color mode."""
|
"""Test the controlling of the state via topic for a light supporting color mode."""
|
||||||
supported_color_modes = ["color_temp", "hs", "rgb", "rgbw", "rgbww", "white", "xy"]
|
supported_color_modes = ["color_temp", "hs", "rgb", "rgbw", "rgbww", "white", "xy"]
|
||||||
|
@ -630,7 +634,7 @@ async def test_controlling_state_via_topic2(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_and_optimistic(
|
async def test_sending_mqtt_commands_and_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending of command in optimistic mode."""
|
"""Test the sending of command in optimistic mode."""
|
||||||
fake_state = State(
|
fake_state = State(
|
||||||
|
@ -777,7 +781,7 @@ async def test_sending_mqtt_commands_and_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_and_optimistic2(
|
async def test_sending_mqtt_commands_and_optimistic2(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending of command in optimistic mode for a light supporting color mode."""
|
"""Test the sending of command in optimistic mode for a light supporting color mode."""
|
||||||
supported_color_modes = ["color_temp", "hs", "rgb", "rgbw", "rgbww", "white", "xy"]
|
supported_color_modes = ["color_temp", "hs", "rgb", "rgbw", "rgbww", "white", "xy"]
|
||||||
|
@ -1009,7 +1013,7 @@ async def test_sending_mqtt_commands_and_optimistic2(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_hs_color(
|
async def test_sending_hs_color(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test light.turn_on with hs color sends hs color parameters."""
|
"""Test light.turn_on with hs color sends hs color parameters."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1072,7 +1076,7 @@ async def test_sending_hs_color(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_rgb_color_no_brightness(
|
async def test_sending_rgb_color_no_brightness(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test light.turn_on with hs color sends rgb color parameters."""
|
"""Test light.turn_on with hs color sends rgb color parameters."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1129,7 +1133,7 @@ async def test_sending_rgb_color_no_brightness(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_rgb_color_no_brightness2(
|
async def test_sending_rgb_color_no_brightness2(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test light.turn_on with hs color sends rgb color parameters."""
|
"""Test light.turn_on with hs color sends rgb color parameters."""
|
||||||
supported_color_modes = ["rgb", "rgbw", "rgbww"]
|
supported_color_modes = ["rgb", "rgbw", "rgbww"]
|
||||||
|
@ -1210,7 +1214,7 @@ async def test_sending_rgb_color_no_brightness2(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_rgb_color_with_brightness(
|
async def test_sending_rgb_color_with_brightness(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test light.turn_on with hs color sends rgb color parameters."""
|
"""Test light.turn_on with hs color sends rgb color parameters."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1278,7 +1282,7 @@ async def test_sending_rgb_color_with_brightness(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_rgb_color_with_scaled_brightness(
|
async def test_sending_rgb_color_with_scaled_brightness(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test light.turn_on with hs color sends rgb color parameters."""
|
"""Test light.turn_on with hs color sends rgb color parameters."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1347,7 +1351,7 @@ async def test_sending_rgb_color_with_scaled_brightness(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_scaled_white(
|
async def test_sending_scaled_white(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test light.turn_on with scaled white."""
|
"""Test light.turn_on with scaled white."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1394,7 +1398,7 @@ async def test_sending_scaled_white(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_xy_color(
|
async def test_sending_xy_color(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test light.turn_on with hs color sends xy color parameters."""
|
"""Test light.turn_on with hs color sends xy color parameters."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1520,7 +1524,7 @@ async def test_effect(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) ->
|
||||||
|
|
||||||
|
|
||||||
async def test_flash_short_and_long(
|
async def test_flash_short_and_long(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for flash length being sent when included."""
|
"""Test for flash length being sent when included."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1585,7 +1589,7 @@ async def test_flash_short_and_long(
|
||||||
|
|
||||||
|
|
||||||
async def test_transition(
|
async def test_transition(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for transition time being sent when included."""
|
"""Test for transition time being sent when included."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1635,7 +1639,7 @@ async def test_transition(
|
||||||
|
|
||||||
|
|
||||||
async def test_brightness_scale(
|
async def test_brightness_scale(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for brightness scaling."""
|
"""Test for brightness scaling."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1680,7 +1684,7 @@ async def test_brightness_scale(
|
||||||
|
|
||||||
|
|
||||||
async def test_white_scale(
|
async def test_white_scale(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for white scaling."""
|
"""Test for white scaling."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1741,7 +1745,7 @@ async def test_white_scale(
|
||||||
|
|
||||||
|
|
||||||
async def test_invalid_values(
|
async def test_invalid_values(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that invalid color/brightness/etc. values are ignored."""
|
"""Test that invalid color/brightness/etc. values are ignored."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1870,7 +1874,7 @@ async def test_invalid_values(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -1879,7 +1883,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -1888,7 +1892,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_payload(
|
await help_test_default_availability_payload(
|
||||||
|
@ -1897,7 +1901,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
await help_test_custom_availability_payload(
|
await help_test_custom_availability_payload(
|
||||||
|
@ -1906,7 +1910,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -1915,7 +1919,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -1928,7 +1932,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -1937,7 +1941,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -1950,7 +1956,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -1963,7 +1971,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -2003,7 +2013,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal(
|
async def test_discovery_removal(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered mqtt_json lights."""
|
"""Test removal of discovered mqtt_json lights."""
|
||||||
data = '{ "name": "test", "schema": "json", "command_topic": "test_topic" }'
|
data = '{ "name": "test", "schema": "json", "command_topic": "test_topic" }'
|
||||||
|
@ -2017,7 +2029,9 @@ async def test_discovery_removal(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_light(
|
async def test_discovery_update_light(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered light."""
|
"""Test update of discovered light."""
|
||||||
config1 = {
|
config1 = {
|
||||||
|
@ -2043,7 +2057,9 @@ async def test_discovery_update_light(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_light(
|
async def test_discovery_update_unchanged_light(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered light."""
|
"""Test update of discovered light."""
|
||||||
data1 = (
|
data1 = (
|
||||||
|
@ -2067,7 +2083,9 @@ async def test_discovery_update_unchanged_light(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer" }'
|
data1 = '{ "name": "Beer" }'
|
||||||
|
@ -2088,7 +2106,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT light device registry integration."""
|
"""Test MQTT light device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -2100,7 +2118,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT light device registry integration."""
|
"""Test MQTT light device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -2112,7 +2130,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -2124,7 +2142,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -2136,7 +2154,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
await help_test_entity_id_update_subscriptions(
|
await help_test_entity_id_update_subscriptions(
|
||||||
|
@ -2145,7 +2163,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -2154,7 +2172,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
await help_test_entity_debug_info_message(
|
await help_test_entity_debug_info_message(
|
||||||
|
@ -2169,7 +2187,7 @@ async def test_entity_debug_info_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_max_mireds(
|
async def test_max_mireds(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting min_mireds and max_mireds."""
|
"""Test setting min_mireds and max_mireds."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -2216,8 +2234,8 @@ async def test_max_mireds(
|
||||||
)
|
)
|
||||||
async def test_publishing_with_custom_encoding(
|
async def test_publishing_with_custom_encoding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
service,
|
service,
|
||||||
topic,
|
topic,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -2249,7 +2267,10 @@ async def test_publishing_with_custom_encoding(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = light.DOMAIN
|
domain = light.DOMAIN
|
||||||
|
@ -2273,8 +2294,8 @@ async def test_reloadable(
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
|
|
@ -25,6 +25,7 @@ If your light doesn't support color temp feature, omit `color_temp_template`.
|
||||||
If your light doesn't support RGB feature, omit `(red|green|blue)_template`.
|
If your light doesn't support RGB feature, omit `(red|green|blue)_template`.
|
||||||
"""
|
"""
|
||||||
import copy
|
import copy
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -76,6 +77,7 @@ from .test_common import (
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message, mock_restore_cache
|
from tests.common import async_fire_mqtt_message, mock_restore_cache
|
||||||
from tests.components.light import common
|
from tests.components.light import common
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
@ -126,7 +128,9 @@ def light_platform_only():
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_setup_fails(hass: HomeAssistant, caplog, test_config) -> None:
|
async def test_setup_fails(
|
||||||
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, test_config
|
||||||
|
) -> None:
|
||||||
"""Test that setup fails with missing required configuration items."""
|
"""Test that setup fails with missing required configuration items."""
|
||||||
assert not await async_setup_component(
|
assert not await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
|
@ -168,7 +172,7 @@ async def test_rgb_light(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_state_change_via_topic(
|
async def test_state_change_via_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test state change via topic."""
|
"""Test state change via topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -223,7 +227,7 @@ async def test_state_change_via_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_state_brightness_color_effect_temp_change_via_topic(
|
async def test_state_brightness_color_effect_temp_change_via_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test state, bri, color, effect, color temp change."""
|
"""Test state, bri, color, effect, color temp change."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -334,7 +338,7 @@ async def test_state_brightness_color_effect_temp_change_via_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_and_optimistic(
|
async def test_sending_mqtt_commands_and_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending of command in optimistic mode."""
|
"""Test the sending of command in optimistic mode."""
|
||||||
fake_state = State(
|
fake_state = State(
|
||||||
|
@ -476,7 +480,7 @@ async def test_sending_mqtt_commands_and_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_non_optimistic_brightness_template(
|
async def test_sending_mqtt_commands_non_optimistic_brightness_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending of command in optimistic mode."""
|
"""Test the sending of command in optimistic mode."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -701,7 +705,7 @@ async def test_flash(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> N
|
||||||
|
|
||||||
|
|
||||||
async def test_transition(
|
async def test_transition(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for transition time being sent when included."""
|
"""Test for transition time being sent when included."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -745,7 +749,7 @@ async def test_transition(
|
||||||
|
|
||||||
|
|
||||||
async def test_invalid_values(
|
async def test_invalid_values(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that invalid values are ignored."""
|
"""Test that invalid values are ignored."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -842,7 +846,7 @@ async def test_invalid_values(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -851,7 +855,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -860,7 +864,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_payload(
|
await help_test_default_availability_payload(
|
||||||
|
@ -869,7 +873,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
await help_test_custom_availability_payload(
|
await help_test_custom_availability_payload(
|
||||||
|
@ -878,7 +882,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -887,7 +891,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -900,7 +904,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -909,7 +913,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -922,7 +928,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -935,7 +943,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -979,7 +989,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal(
|
async def test_discovery_removal(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered mqtt_json lights."""
|
"""Test removal of discovered mqtt_json lights."""
|
||||||
data = (
|
data = (
|
||||||
|
@ -995,7 +1007,9 @@ async def test_discovery_removal(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_light(
|
async def test_discovery_update_light(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered light."""
|
"""Test update of discovered light."""
|
||||||
config1 = {
|
config1 = {
|
||||||
|
@ -1020,7 +1034,9 @@ async def test_discovery_update_light(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_light(
|
async def test_discovery_update_unchanged_light(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered light."""
|
"""Test update of discovered light."""
|
||||||
data1 = (
|
data1 = (
|
||||||
|
@ -1046,7 +1062,9 @@ async def test_discovery_update_unchanged_light(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer" }'
|
data1 = '{ "name": "Beer" }'
|
||||||
|
@ -1064,7 +1082,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT light device registry integration."""
|
"""Test MQTT light device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -1073,7 +1091,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT light device registry integration."""
|
"""Test MQTT light device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -1082,7 +1100,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -1091,7 +1109,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -1100,7 +1118,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
await help_test_entity_id_update_subscriptions(
|
await help_test_entity_id_update_subscriptions(
|
||||||
|
@ -1109,7 +1127,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -1118,7 +1136,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1143,7 +1161,7 @@ async def test_entity_debug_info_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_max_mireds(
|
async def test_max_mireds(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting min_mireds and max_mireds."""
|
"""Test setting min_mireds and max_mireds."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -1192,8 +1210,8 @@ async def test_max_mireds(
|
||||||
)
|
)
|
||||||
async def test_publishing_with_custom_encoding(
|
async def test_publishing_with_custom_encoding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
service,
|
service,
|
||||||
topic,
|
topic,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -1225,7 +1243,10 @@ async def test_publishing_with_custom_encoding(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = light.DOMAIN
|
domain = light.DOMAIN
|
||||||
|
@ -1243,8 +1264,8 @@ async def test_reloadable(
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
@ -1276,7 +1297,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = light.DOMAIN
|
domain = light.DOMAIN
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
"""The tests for the MQTT lock platform."""
|
"""The tests for the MQTT lock platform."""
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -57,6 +58,7 @@ from .test_common import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message
|
from tests.common import async_fire_mqtt_message
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {lock.DOMAIN: {"name": "test", "command_topic": "test-topic"}}
|
mqtt.DOMAIN: {lock.DOMAIN: {"name": "test", "command_topic": "test-topic"}}
|
||||||
|
@ -80,7 +82,10 @@ def lock_platform_only():
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_controlling_state_via_topic(
|
async def test_controlling_state_via_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, payload, lock_state
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
payload,
|
||||||
|
lock_state,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic."""
|
"""Test the controlling state via topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -126,7 +131,10 @@ async def test_controlling_state_via_topic(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_controlling_non_default_state_via_topic(
|
async def test_controlling_non_default_state_via_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, payload, lock_state
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
payload,
|
||||||
|
lock_state,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic."""
|
"""Test the controlling state via topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -171,7 +179,10 @@ async def test_controlling_non_default_state_via_topic(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_controlling_state_via_topic_and_json_message(
|
async def test_controlling_state_via_topic_and_json_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, payload, lock_state
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
payload,
|
||||||
|
lock_state,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic and JSON message."""
|
"""Test the controlling state via topic and JSON message."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -216,7 +227,10 @@ async def test_controlling_state_via_topic_and_json_message(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_controlling_non_default_state_via_topic_and_json_message(
|
async def test_controlling_non_default_state_via_topic_and_json_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, payload, lock_state
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
payload,
|
||||||
|
lock_state,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic and JSON message."""
|
"""Test the controlling state via topic and JSON message."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -252,7 +266,7 @@ async def test_controlling_non_default_state_via_topic_and_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_and_optimistic(
|
async def test_sending_mqtt_commands_and_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test optimistic mode without state topic."""
|
"""Test optimistic mode without state topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -300,7 +314,7 @@ async def test_sending_mqtt_commands_and_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_with_template(
|
async def test_sending_mqtt_commands_with_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test sending commands with template."""
|
"""Test sending commands with template."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -361,7 +375,7 @@ async def test_sending_mqtt_commands_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_and_explicit_optimistic(
|
async def test_sending_mqtt_commands_and_explicit_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test optimistic mode without state topic."""
|
"""Test optimistic mode without state topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -411,7 +425,7 @@ async def test_sending_mqtt_commands_and_explicit_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_support_open_and_optimistic(
|
async def test_sending_mqtt_commands_support_open_and_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test open function of the lock without state topic."""
|
"""Test open function of the lock without state topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -471,7 +485,7 @@ async def test_sending_mqtt_commands_support_open_and_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_support_open_and_explicit_optimistic(
|
async def test_sending_mqtt_commands_support_open_and_explicit_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test open function of the lock without state topic."""
|
"""Test open function of the lock without state topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -533,7 +547,7 @@ async def test_sending_mqtt_commands_support_open_and_explicit_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_pessimistic(
|
async def test_sending_mqtt_commands_pessimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test function of the lock with state topics."""
|
"""Test function of the lock with state topics."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -639,7 +653,7 @@ async def test_sending_mqtt_commands_pessimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -648,7 +662,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -657,7 +671,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_payload(
|
await help_test_default_availability_payload(
|
||||||
|
@ -666,7 +680,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
await help_test_custom_availability_payload(
|
await help_test_custom_availability_payload(
|
||||||
|
@ -675,7 +689,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -684,7 +698,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -697,7 +711,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -706,7 +720,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -719,7 +735,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -732,7 +750,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -766,7 +786,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_lock(
|
async def test_discovery_removal_lock(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered lock."""
|
"""Test removal of discovered lock."""
|
||||||
data = '{ "name": "test",' ' "command_topic": "test_topic" }'
|
data = '{ "name": "test",' ' "command_topic": "test_topic" }'
|
||||||
|
@ -776,7 +798,9 @@ async def test_discovery_removal_lock(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_lock(
|
async def test_discovery_update_lock(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered lock."""
|
"""Test update of discovered lock."""
|
||||||
config1 = {
|
config1 = {
|
||||||
|
@ -797,7 +821,9 @@ async def test_discovery_update_lock(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_lock(
|
async def test_discovery_update_unchanged_lock(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered lock."""
|
"""Test update of discovered lock."""
|
||||||
data1 = (
|
data1 = (
|
||||||
|
@ -820,7 +846,9 @@ async def test_discovery_update_unchanged_lock(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer" }'
|
data1 = '{ "name": "Beer" }'
|
||||||
|
@ -831,7 +859,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT lock device registry integration."""
|
"""Test MQTT lock device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -840,7 +868,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT lock device registry integration."""
|
"""Test MQTT lock device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -849,7 +877,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -858,7 +886,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -867,7 +895,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
await help_test_entity_id_update_subscriptions(
|
await help_test_entity_id_update_subscriptions(
|
||||||
|
@ -876,7 +904,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -885,7 +913,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
await help_test_entity_debug_info_message(
|
await help_test_entity_debug_info_message(
|
||||||
|
@ -912,8 +940,8 @@ async def test_entity_debug_info_message(
|
||||||
)
|
)
|
||||||
async def test_publishing_with_custom_encoding(
|
async def test_publishing_with_custom_encoding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
service,
|
service,
|
||||||
topic,
|
topic,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -939,7 +967,10 @@ async def test_publishing_with_custom_encoding(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = lock.DOMAIN
|
domain = lock.DOMAIN
|
||||||
|
@ -957,8 +988,8 @@ async def test_reloadable(
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
@ -979,7 +1010,7 @@ async def test_encoding_subscribable_topics(
|
||||||
|
|
||||||
|
|
||||||
async def test_setup_manual_entity_from_yaml(
|
async def test_setup_manual_entity_from_yaml(
|
||||||
hass: HomeAssistant, caplog, tmp_path
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, tmp_path
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setup manual configured MQTT entity."""
|
"""Test setup manual configured MQTT entity."""
|
||||||
platform = lock.DOMAIN
|
platform = lock.DOMAIN
|
||||||
|
@ -988,7 +1019,9 @@ async def test_setup_manual_entity_from_yaml(
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = lock.DOMAIN
|
domain = lock.DOMAIN
|
||||||
|
|
|
@ -8,12 +8,13 @@ from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message
|
from tests.common import async_fire_mqtt_message
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
|
|
||||||
@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SENSOR])
|
@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SENSOR])
|
||||||
async def test_availability_with_shared_state_topic(
|
async def test_availability_with_shared_state_topic(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the state is not changed twice.
|
"""Test the state is not changed twice.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""The tests for mqtt number component."""
|
"""The tests for mqtt number component."""
|
||||||
import json
|
import json
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -62,6 +63,7 @@ from .test_common import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message, mock_restore_cache_with_extra_data
|
from tests.common import async_fire_mqtt_message, mock_restore_cache_with_extra_data
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {number.DOMAIN: {"name": "test", "command_topic": "test-topic"}}
|
mqtt.DOMAIN: {number.DOMAIN: {"name": "test", "command_topic": "test-topic"}}
|
||||||
|
@ -76,7 +78,7 @@ def number_platform_only():
|
||||||
|
|
||||||
|
|
||||||
async def test_run_number_setup(
|
async def test_run_number_setup(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that it fetches the given payload."""
|
"""Test that it fetches the given payload."""
|
||||||
topic = "test/number"
|
topic = "test/number"
|
||||||
|
@ -128,7 +130,7 @@ async def test_run_number_setup(
|
||||||
|
|
||||||
|
|
||||||
async def test_value_template(
|
async def test_value_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that it fetches the given payload with a template."""
|
"""Test that it fetches the given payload with a template."""
|
||||||
topic = "test/number"
|
topic = "test/number"
|
||||||
|
@ -172,7 +174,7 @@ async def test_value_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_restore_native_value(
|
async def test_restore_native_value(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that the stored native_value is restored."""
|
"""Test that the stored native_value is restored."""
|
||||||
topic = "test/number"
|
topic = "test/number"
|
||||||
|
@ -211,7 +213,7 @@ async def test_restore_native_value(
|
||||||
|
|
||||||
|
|
||||||
async def test_run_number_service_optimistic(
|
async def test_run_number_service_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that set_value service works in optimistic mode."""
|
"""Test that set_value service works in optimistic mode."""
|
||||||
topic = "test/number"
|
topic = "test/number"
|
||||||
|
@ -287,7 +289,7 @@ async def test_run_number_service_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_run_number_service_optimistic_with_command_template(
|
async def test_run_number_service_optimistic_with_command_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that set_value service works in optimistic mode and with a command_template."""
|
"""Test that set_value service works in optimistic mode and with a command_template."""
|
||||||
topic = "test/number"
|
topic = "test/number"
|
||||||
|
@ -366,7 +368,7 @@ async def test_run_number_service_optimistic_with_command_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_run_number_service(
|
async def test_run_number_service(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that set_value service works in non optimistic mode."""
|
"""Test that set_value service works in non optimistic mode."""
|
||||||
cmd_topic = "test/number/set"
|
cmd_topic = "test/number/set"
|
||||||
|
@ -404,7 +406,7 @@ async def test_run_number_service(
|
||||||
|
|
||||||
|
|
||||||
async def test_run_number_service_with_command_template(
|
async def test_run_number_service_with_command_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that set_value service works in non optimistic mode and with a command_template."""
|
"""Test that set_value service works in non optimistic mode and with a command_template."""
|
||||||
cmd_topic = "test/number/set"
|
cmd_topic = "test/number/set"
|
||||||
|
@ -445,7 +447,7 @@ async def test_run_number_service_with_command_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -454,7 +456,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -463,7 +465,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_payload(
|
await help_test_default_availability_payload(
|
||||||
|
@ -472,7 +474,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
await help_test_custom_availability_payload(
|
await help_test_custom_availability_payload(
|
||||||
|
@ -481,7 +483,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -490,7 +492,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -503,7 +505,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -512,7 +514,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -525,7 +529,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -538,7 +544,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -576,7 +584,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_number(
|
async def test_discovery_removal_number(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered number."""
|
"""Test removal of discovered number."""
|
||||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][number.DOMAIN])
|
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][number.DOMAIN])
|
||||||
|
@ -586,7 +596,9 @@ async def test_discovery_removal_number(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_number(
|
async def test_discovery_update_number(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered number."""
|
"""Test update of discovered number."""
|
||||||
config1 = {
|
config1 = {
|
||||||
|
@ -606,7 +618,9 @@ async def test_discovery_update_number(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_number(
|
async def test_discovery_update_unchanged_number(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered number."""
|
"""Test update of discovered number."""
|
||||||
data1 = (
|
data1 = (
|
||||||
|
@ -627,7 +641,9 @@ async def test_discovery_update_unchanged_number(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer" }'
|
data1 = '{ "name": "Beer" }'
|
||||||
|
@ -641,7 +657,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT number device registry integration."""
|
"""Test MQTT number device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -650,7 +666,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT number device registry integration."""
|
"""Test MQTT number device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -659,7 +675,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -668,7 +684,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -677,7 +693,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
await help_test_entity_id_update_subscriptions(
|
await help_test_entity_id_update_subscriptions(
|
||||||
|
@ -686,7 +702,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -695,7 +711,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
await help_test_entity_debug_info_message(
|
await help_test_entity_debug_info_message(
|
||||||
|
@ -711,7 +727,7 @@ async def test_entity_debug_info_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_min_max_step_attributes(
|
async def test_min_max_step_attributes(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test min/max/step attributes."""
|
"""Test min/max/step attributes."""
|
||||||
topic = "test/number"
|
topic = "test/number"
|
||||||
|
@ -763,7 +779,7 @@ async def test_invalid_min_max_attributes(hass: HomeAssistant, caplog) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_default_mode(
|
async def test_default_mode(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test default mode."""
|
"""Test default mode."""
|
||||||
topic = "test/number"
|
topic = "test/number"
|
||||||
|
@ -789,7 +805,9 @@ async def test_default_mode(
|
||||||
|
|
||||||
@pytest.mark.parametrize("mode", ("auto", "box", "slider"))
|
@pytest.mark.parametrize("mode", ("auto", "box", "slider"))
|
||||||
async def test_mode(
|
async def test_mode(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, mode
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
mode,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test mode."""
|
"""Test mode."""
|
||||||
topic = "test/number"
|
topic = "test/number"
|
||||||
|
@ -838,7 +856,9 @@ async def test_invalid_mode(hass: HomeAssistant, mode, valid) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_mqtt_payload_not_a_number_warning(
|
async def test_mqtt_payload_not_a_number_warning(
|
||||||
hass: HomeAssistant, caplog, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test warning for MQTT payload which is not a number."""
|
"""Test warning for MQTT payload which is not a number."""
|
||||||
topic = "test/number"
|
topic = "test/number"
|
||||||
|
@ -866,7 +886,9 @@ async def test_mqtt_payload_not_a_number_warning(
|
||||||
|
|
||||||
|
|
||||||
async def test_mqtt_payload_out_of_range_error(
|
async def test_mqtt_payload_out_of_range_error(
|
||||||
hass: HomeAssistant, caplog, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test error when MQTT payload is out of min/max range."""
|
"""Test error when MQTT payload is out of min/max range."""
|
||||||
topic = "test/number"
|
topic = "test/number"
|
||||||
|
@ -911,8 +933,8 @@ async def test_mqtt_payload_out_of_range_error(
|
||||||
)
|
)
|
||||||
async def test_publishing_with_custom_encoding(
|
async def test_publishing_with_custom_encoding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
service,
|
service,
|
||||||
topic,
|
topic,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -938,7 +960,10 @@ async def test_publishing_with_custom_encoding(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = number.DOMAIN
|
domain = number.DOMAIN
|
||||||
|
@ -957,8 +982,8 @@ async def test_reloadable(
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
@ -986,7 +1011,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = number.DOMAIN
|
domain = number.DOMAIN
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""The tests for the MQTT scene platform."""
|
"""The tests for the MQTT scene platform."""
|
||||||
import copy
|
import copy
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -25,6 +26,7 @@ from .test_common import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.common import mock_restore_cache
|
from tests.common import mock_restore_cache
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
@ -45,7 +47,7 @@ def scene_platform_only():
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands(
|
async def test_sending_mqtt_commands(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending MQTT commands."""
|
"""Test the sending MQTT commands."""
|
||||||
fake_state = State("scene.test", STATE_UNKNOWN)
|
fake_state = State("scene.test", STATE_UNKNOWN)
|
||||||
|
@ -79,7 +81,7 @@ async def test_sending_mqtt_commands(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -88,7 +90,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -97,7 +99,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -122,7 +124,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -170,7 +172,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_scene(
|
async def test_discovery_removal_scene(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered scene."""
|
"""Test removal of discovered scene."""
|
||||||
data = '{ "name": "test",' ' "command_topic": "test_topic" }'
|
data = '{ "name": "test",' ' "command_topic": "test_topic" }'
|
||||||
|
@ -180,7 +184,9 @@ async def test_discovery_removal_scene(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_payload(
|
async def test_discovery_update_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered scene."""
|
"""Test update of discovered scene."""
|
||||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][scene.DOMAIN])
|
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][scene.DOMAIN])
|
||||||
|
@ -201,7 +207,9 @@ async def test_discovery_update_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_scene(
|
async def test_discovery_update_unchanged_scene(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered scene."""
|
"""Test update of discovered scene."""
|
||||||
data1 = '{ "name": "Beer",' ' "command_topic": "test_topic" }'
|
data1 = '{ "name": "Beer",' ' "command_topic": "test_topic" }'
|
||||||
|
@ -220,7 +228,9 @@ async def test_discovery_update_unchanged_scene(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer" }'
|
data1 = '{ "name": "Beer" }'
|
||||||
|
@ -231,7 +241,10 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = scene.DOMAIN
|
domain = scene.DOMAIN
|
||||||
|
@ -249,7 +262,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = scene.DOMAIN
|
domain = scene.DOMAIN
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""The tests for mqtt select component."""
|
"""The tests for mqtt select component."""
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -54,6 +55,7 @@ from .test_common import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message, mock_restore_cache
|
from tests.common import async_fire_mqtt_message, mock_restore_cache
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
@ -74,7 +76,7 @@ def select_platform_only():
|
||||||
|
|
||||||
|
|
||||||
async def test_run_select_setup(
|
async def test_run_select_setup(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that it fetches the given payload."""
|
"""Test that it fetches the given payload."""
|
||||||
topic = "test/select"
|
topic = "test/select"
|
||||||
|
@ -111,7 +113,7 @@ async def test_run_select_setup(
|
||||||
|
|
||||||
|
|
||||||
async def test_value_template(
|
async def test_value_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that it fetches the given payload with a template."""
|
"""Test that it fetches the given payload with a template."""
|
||||||
topic = "test/select"
|
topic = "test/select"
|
||||||
|
@ -156,7 +158,7 @@ async def test_value_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_run_select_service_optimistic(
|
async def test_run_select_service_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that set_value service works in optimistic mode."""
|
"""Test that set_value service works in optimistic mode."""
|
||||||
topic = "test/select"
|
topic = "test/select"
|
||||||
|
@ -198,7 +200,7 @@ async def test_run_select_service_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_run_select_service_optimistic_with_command_template(
|
async def test_run_select_service_optimistic_with_command_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that set_value service works in optimistic mode and with a command_template."""
|
"""Test that set_value service works in optimistic mode and with a command_template."""
|
||||||
topic = "test/select"
|
topic = "test/select"
|
||||||
|
@ -243,7 +245,7 @@ async def test_run_select_service_optimistic_with_command_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_run_select_service(
|
async def test_run_select_service(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that set_value service works in non optimistic mode."""
|
"""Test that set_value service works in non optimistic mode."""
|
||||||
cmd_topic = "test/select/set"
|
cmd_topic = "test/select/set"
|
||||||
|
@ -282,7 +284,7 @@ async def test_run_select_service(
|
||||||
|
|
||||||
|
|
||||||
async def test_run_select_service_with_command_template(
|
async def test_run_select_service_with_command_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that set_value service works in non optimistic mode and with a command_template."""
|
"""Test that set_value service works in non optimistic mode and with a command_template."""
|
||||||
cmd_topic = "test/select/set"
|
cmd_topic = "test/select/set"
|
||||||
|
@ -322,7 +324,7 @@ async def test_run_select_service_with_command_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -331,7 +333,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -340,7 +342,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_payload(
|
await help_test_default_availability_payload(
|
||||||
|
@ -349,7 +351,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
await help_test_custom_availability_payload(
|
await help_test_custom_availability_payload(
|
||||||
|
@ -358,7 +360,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -367,7 +369,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -380,7 +382,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -389,7 +391,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -402,7 +406,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -415,7 +421,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -455,7 +463,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_select(
|
async def test_discovery_removal_select(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered select."""
|
"""Test removal of discovered select."""
|
||||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][select.DOMAIN])
|
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][select.DOMAIN])
|
||||||
|
@ -465,7 +475,9 @@ async def test_discovery_removal_select(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_select(
|
async def test_discovery_update_select(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered select."""
|
"""Test update of discovered select."""
|
||||||
config1 = {
|
config1 = {
|
||||||
|
@ -487,7 +499,9 @@ async def test_discovery_update_select(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_select(
|
async def test_discovery_update_unchanged_select(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered select."""
|
"""Test update of discovered select."""
|
||||||
data1 = '{ "name": "Beer", "state_topic": "test-topic", "command_topic": "test-topic", "options": ["milk", "beer"]}'
|
data1 = '{ "name": "Beer", "state_topic": "test-topic", "command_topic": "test-topic", "options": ["milk", "beer"]}'
|
||||||
|
@ -506,7 +520,9 @@ async def test_discovery_update_unchanged_select(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer" }'
|
data1 = '{ "name": "Beer" }'
|
||||||
|
@ -518,7 +534,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT select device registry integration."""
|
"""Test MQTT select device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -527,7 +543,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT select device registry integration."""
|
"""Test MQTT select device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -536,7 +552,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -545,7 +561,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -554,7 +570,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
await help_test_entity_id_update_subscriptions(
|
await help_test_entity_id_update_subscriptions(
|
||||||
|
@ -563,7 +579,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -572,7 +588,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
await help_test_entity_debug_info_message(
|
await help_test_entity_debug_info_message(
|
||||||
|
@ -589,7 +605,9 @@ async def test_entity_debug_info_message(
|
||||||
|
|
||||||
@pytest.mark.parametrize("options", [["milk", "beer"], ["milk"], []])
|
@pytest.mark.parametrize("options", [["milk", "beer"], ["milk"], []])
|
||||||
async def test_options_attributes(
|
async def test_options_attributes(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, options
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
options,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test options attribute."""
|
"""Test options attribute."""
|
||||||
topic = "test/select"
|
topic = "test/select"
|
||||||
|
@ -615,7 +633,9 @@ async def test_options_attributes(
|
||||||
|
|
||||||
|
|
||||||
async def test_mqtt_payload_not_an_option_warning(
|
async def test_mqtt_payload_not_an_option_warning(
|
||||||
hass: HomeAssistant, caplog, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test warning for MQTT payload which is not a valid option."""
|
"""Test warning for MQTT payload which is not a valid option."""
|
||||||
topic = "test/select"
|
topic = "test/select"
|
||||||
|
@ -660,8 +680,8 @@ async def test_mqtt_payload_not_an_option_warning(
|
||||||
)
|
)
|
||||||
async def test_publishing_with_custom_encoding(
|
async def test_publishing_with_custom_encoding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
service,
|
service,
|
||||||
topic,
|
topic,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -688,7 +708,10 @@ async def test_publishing_with_custom_encoding(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = select.DOMAIN
|
domain = select.DOMAIN
|
||||||
|
@ -707,8 +730,8 @@ async def test_reloadable(
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
@ -738,7 +761,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = select.DOMAIN
|
domain = select.DOMAIN
|
||||||
|
@ -749,7 +774,7 @@ async def test_unload_entry(
|
||||||
|
|
||||||
|
|
||||||
async def test_persistent_state_after_reconfig(
|
async def test_persistent_state_after_reconfig(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test of the state is persistent after reconfiguring the select options."""
|
"""Test of the state is persistent after reconfiguring the select options."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import copy
|
import copy
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import json
|
import json
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -66,6 +67,7 @@ from tests.common import (
|
||||||
async_fire_time_changed,
|
async_fire_time_changed,
|
||||||
mock_restore_cache_with_extra_data,
|
mock_restore_cache_with_extra_data,
|
||||||
)
|
)
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {sensor.DOMAIN: {"name": "test", "state_topic": "test-topic"}}
|
mqtt.DOMAIN: {sensor.DOMAIN: {"name": "test", "state_topic": "test-topic"}}
|
||||||
|
@ -80,7 +82,7 @@ def sensor_platform_only():
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_sensor_value_via_mqtt_message(
|
async def test_setting_sensor_value_via_mqtt_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the value via MQTT."""
|
"""Test the setting of the value via MQTT."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -137,8 +139,8 @@ async def test_setting_sensor_value_via_mqtt_message(
|
||||||
)
|
)
|
||||||
async def test_setting_sensor_native_value_handling_via_mqtt_message(
|
async def test_setting_sensor_native_value_handling_via_mqtt_message(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
device_class,
|
device_class,
|
||||||
native_value,
|
native_value,
|
||||||
state_value,
|
state_value,
|
||||||
|
@ -171,7 +173,7 @@ async def test_setting_sensor_native_value_handling_via_mqtt_message(
|
||||||
|
|
||||||
async def test_setting_numeric_sensor_native_value_handling_via_mqtt_message(
|
async def test_setting_numeric_sensor_native_value_handling_via_mqtt_message(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of a numeric sensor value via MQTT."""
|
"""Test the setting of a numeric sensor value via MQTT."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -225,7 +227,9 @@ async def test_setting_numeric_sensor_native_value_handling_via_mqtt_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_sensor_value_expires_availability_topic(
|
async def test_setting_sensor_value_expires_availability_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the expiration of the value."""
|
"""Test the expiration of the value."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -259,7 +263,9 @@ async def test_setting_sensor_value_expires_availability_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_sensor_value_expires(
|
async def test_setting_sensor_value_expires(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the expiration of the value."""
|
"""Test the expiration of the value."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -339,7 +345,7 @@ async def expires_helper(hass: HomeAssistant, caplog) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_sensor_value_via_mqtt_json_message(
|
async def test_setting_sensor_value_via_mqtt_json_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the value via MQTT with JSON payload."""
|
"""Test the setting of the value via MQTT with JSON payload."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -371,7 +377,7 @@ async def test_setting_sensor_value_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_sensor_value_via_mqtt_json_message_and_default_current_state(
|
async def test_setting_sensor_value_via_mqtt_json_message_and_default_current_state(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the value via MQTT with fall back to current state."""
|
"""Test the setting of the value via MQTT with fall back to current state."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -404,7 +410,9 @@ async def test_setting_sensor_value_via_mqtt_json_message_and_default_current_st
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_sensor_last_reset_via_mqtt_message(
|
async def test_setting_sensor_last_reset_via_mqtt_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the last_reset property via MQTT."""
|
"""Test the setting of the last_reset property via MQTT."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -437,7 +445,10 @@ async def test_setting_sensor_last_reset_via_mqtt_message(
|
||||||
|
|
||||||
@pytest.mark.parametrize("datestring", ["2020-21-02 08:11:00", "Hello there!"])
|
@pytest.mark.parametrize("datestring", ["2020-21-02 08:11:00", "Hello there!"])
|
||||||
async def test_setting_sensor_bad_last_reset_via_mqtt_message(
|
async def test_setting_sensor_bad_last_reset_via_mqtt_message(
|
||||||
hass: HomeAssistant, caplog, datestring, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
datestring,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the last_reset property via MQTT."""
|
"""Test the setting of the last_reset property via MQTT."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -465,7 +476,7 @@ async def test_setting_sensor_bad_last_reset_via_mqtt_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_sensor_empty_last_reset_via_mqtt_message(
|
async def test_setting_sensor_empty_last_reset_via_mqtt_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the last_reset property via MQTT."""
|
"""Test the setting of the last_reset property via MQTT."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -492,7 +503,7 @@ async def test_setting_sensor_empty_last_reset_via_mqtt_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_sensor_last_reset_via_mqtt_json_message(
|
async def test_setting_sensor_last_reset_via_mqtt_json_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the value via MQTT with JSON payload."""
|
"""Test the setting of the value via MQTT with JSON payload."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -523,7 +534,10 @@ async def test_setting_sensor_last_reset_via_mqtt_json_message(
|
||||||
|
|
||||||
@pytest.mark.parametrize("extra", [{}, {"last_reset_topic": "test-topic"}])
|
@pytest.mark.parametrize("extra", [{}, {"last_reset_topic": "test-topic"}])
|
||||||
async def test_setting_sensor_last_reset_via_mqtt_json_message_2(
|
async def test_setting_sensor_last_reset_via_mqtt_json_message_2(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog, extra
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
extra,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the setting of the value via MQTT with JSON payload."""
|
"""Test the setting of the value via MQTT with JSON payload."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -564,7 +578,7 @@ async def test_setting_sensor_last_reset_via_mqtt_json_message_2(
|
||||||
|
|
||||||
|
|
||||||
async def test_force_update_disabled(
|
async def test_force_update_disabled(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test force update option."""
|
"""Test force update option."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -601,7 +615,7 @@ async def test_force_update_disabled(
|
||||||
|
|
||||||
|
|
||||||
async def test_force_update_enabled(
|
async def test_force_update_enabled(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test force update option."""
|
"""Test force update option."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -639,7 +653,7 @@ async def test_force_update_enabled(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -648,7 +662,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -657,7 +671,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_payload(
|
await help_test_default_availability_payload(
|
||||||
|
@ -666,7 +680,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_list_payload(
|
async def test_default_availability_list_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_list_payload(
|
await help_test_default_availability_list_payload(
|
||||||
|
@ -675,7 +689,7 @@ async def test_default_availability_list_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_list_payload_all(
|
async def test_default_availability_list_payload_all(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_list_payload_all(
|
await help_test_default_availability_list_payload_all(
|
||||||
|
@ -684,7 +698,7 @@ async def test_default_availability_list_payload_all(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_list_payload_any(
|
async def test_default_availability_list_payload_any(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_list_payload_any(
|
await help_test_default_availability_list_payload_any(
|
||||||
|
@ -703,7 +717,7 @@ async def test_default_availability_list_single(hass: HomeAssistant, caplog) ->
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
await help_test_custom_availability_payload(
|
await help_test_custom_availability_payload(
|
||||||
|
@ -712,7 +726,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_availability(
|
async def test_discovery_update_availability(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability discovery update."""
|
"""Test availability discovery update."""
|
||||||
await help_test_discovery_update_availability(
|
await help_test_discovery_update_availability(
|
||||||
|
@ -721,7 +735,7 @@ async def test_discovery_update_availability(
|
||||||
|
|
||||||
|
|
||||||
async def test_invalid_device_class(
|
async def test_invalid_device_class(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test device_class option with invalid value."""
|
"""Test device_class option with invalid value."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -745,7 +759,7 @@ async def test_invalid_device_class(
|
||||||
|
|
||||||
|
|
||||||
async def test_valid_device_class(
|
async def test_valid_device_class(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test device_class option with valid values."""
|
"""Test device_class option with valid values."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -781,7 +795,7 @@ async def test_valid_device_class(
|
||||||
|
|
||||||
|
|
||||||
async def test_invalid_state_class(
|
async def test_invalid_state_class(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test state_class option with invalid value."""
|
"""Test state_class option with invalid value."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -805,7 +819,7 @@ async def test_invalid_state_class(
|
||||||
|
|
||||||
|
|
||||||
async def test_valid_state_class(
|
async def test_valid_state_class(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test state_class option with valid values."""
|
"""Test state_class option with valid values."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -841,7 +855,7 @@ async def test_valid_state_class(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -850,7 +864,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -863,7 +877,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -872,7 +886,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -885,7 +901,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -898,7 +916,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -934,7 +954,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_sensor(
|
async def test_discovery_removal_sensor(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered sensor."""
|
"""Test removal of discovered sensor."""
|
||||||
data = '{ "name": "test", "state_topic": "test_topic" }'
|
data = '{ "name": "test", "state_topic": "test_topic" }'
|
||||||
|
@ -944,7 +966,9 @@ async def test_discovery_removal_sensor(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_sensor_topic_template(
|
async def test_discovery_update_sensor_topic_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered sensor."""
|
"""Test update of discovered sensor."""
|
||||||
config = {"name": "test", "state_topic": "test_topic"}
|
config = {"name": "test", "state_topic": "test_topic"}
|
||||||
|
@ -979,7 +1003,9 @@ async def test_discovery_update_sensor_topic_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_sensor_template(
|
async def test_discovery_update_sensor_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered sensor."""
|
"""Test update of discovered sensor."""
|
||||||
config = {"name": "test", "state_topic": "test_topic"}
|
config = {"name": "test", "state_topic": "test_topic"}
|
||||||
|
@ -1012,7 +1038,9 @@ async def test_discovery_update_sensor_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_sensor(
|
async def test_discovery_update_unchanged_sensor(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered sensor."""
|
"""Test update of discovered sensor."""
|
||||||
data1 = '{ "name": "Beer", "state_topic": "test_topic" }'
|
data1 = '{ "name": "Beer", "state_topic": "test_topic" }'
|
||||||
|
@ -1031,7 +1059,9 @@ async def test_discovery_update_unchanged_sensor(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer", "state_topic": "test_topic#" }'
|
data1 = '{ "name": "Beer", "state_topic": "test_topic#" }'
|
||||||
|
@ -1042,7 +1072,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT sensor device registry integration."""
|
"""Test MQTT sensor device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -1051,7 +1081,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT sensor device registry integration."""
|
"""Test MQTT sensor device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -1060,7 +1090,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -1069,7 +1099,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -1078,7 +1108,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
await help_test_entity_id_update_subscriptions(
|
await help_test_entity_id_update_subscriptions(
|
||||||
|
@ -1087,7 +1117,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -1096,7 +1126,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_hub(
|
async def test_entity_device_info_with_hub(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test MQTT sensor device registry integration."""
|
"""Test MQTT sensor device registry integration."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -1126,7 +1156,7 @@ async def test_entity_device_info_with_hub(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info(
|
async def test_entity_debug_info(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test MQTT sensor debug info."""
|
"""Test MQTT sensor debug info."""
|
||||||
await help_test_entity_debug_info(
|
await help_test_entity_debug_info(
|
||||||
|
@ -1135,7 +1165,7 @@ async def test_entity_debug_info(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_max_messages(
|
async def test_entity_debug_info_max_messages(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test MQTT sensor debug info."""
|
"""Test MQTT sensor debug info."""
|
||||||
await help_test_entity_debug_info_max_messages(
|
await help_test_entity_debug_info_max_messages(
|
||||||
|
@ -1144,7 +1174,7 @@ async def test_entity_debug_info_max_messages(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
await help_test_entity_debug_info_message(
|
await help_test_entity_debug_info_message(
|
||||||
|
@ -1153,7 +1183,7 @@ async def test_entity_debug_info_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_remove(
|
async def test_entity_debug_info_remove(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test MQTT sensor debug info."""
|
"""Test MQTT sensor debug info."""
|
||||||
await help_test_entity_debug_info_remove(
|
await help_test_entity_debug_info_remove(
|
||||||
|
@ -1162,7 +1192,7 @@ async def test_entity_debug_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_update_entity_id(
|
async def test_entity_debug_info_update_entity_id(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test MQTT sensor debug info."""
|
"""Test MQTT sensor debug info."""
|
||||||
await help_test_entity_debug_info_update_entity_id(
|
await help_test_entity_debug_info_update_entity_id(
|
||||||
|
@ -1171,7 +1201,7 @@ async def test_entity_debug_info_update_entity_id(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_disabled_by_default(
|
async def test_entity_disabled_by_default(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test entity disabled by default."""
|
"""Test entity disabled by default."""
|
||||||
await help_test_entity_disabled_by_default(
|
await help_test_entity_disabled_by_default(
|
||||||
|
@ -1181,7 +1211,7 @@ async def test_entity_disabled_by_default(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_entity_category(
|
async def test_entity_category(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test entity category."""
|
"""Test entity category."""
|
||||||
await help_test_entity_category(
|
await help_test_entity_category(
|
||||||
|
@ -1190,7 +1220,7 @@ async def test_entity_category(
|
||||||
|
|
||||||
|
|
||||||
async def test_value_template_with_entity_id(
|
async def test_value_template_with_entity_id(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the access to attributes in value_template via the entity_id."""
|
"""Test the access to attributes in value_template via the entity_id."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1222,7 +1252,10 @@ async def test_value_template_with_entity_id(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = sensor.DOMAIN
|
domain = sensor.DOMAIN
|
||||||
|
@ -1233,7 +1266,11 @@ async def test_reloadable(
|
||||||
|
|
||||||
|
|
||||||
async def test_cleanup_triggers_and_restoring_state(
|
async def test_cleanup_triggers_and_restoring_state(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog, tmp_path, freezer
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
tmp_path: Path,
|
||||||
|
freezer,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test cleanup old triggers at reloading and restoring the state."""
|
"""Test cleanup old triggers at reloading and restoring the state."""
|
||||||
domain = sensor.DOMAIN
|
domain = sensor.DOMAIN
|
||||||
|
@ -1291,7 +1328,9 @@ async def test_cleanup_triggers_and_restoring_state(
|
||||||
|
|
||||||
|
|
||||||
async def test_skip_restoring_state_with_over_due_expire_trigger(
|
async def test_skip_restoring_state_with_over_due_expire_trigger(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, freezer
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
freezer,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test restoring a state with over due expire timer."""
|
"""Test restoring a state with over due expire timer."""
|
||||||
|
|
||||||
|
@ -1328,8 +1367,8 @@ async def test_skip_restoring_state_with_over_due_expire_trigger(
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
@ -1358,7 +1397,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = sensor.DOMAIN
|
domain = sensor.DOMAIN
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""The tests for the MQTT siren platform."""
|
"""The tests for the MQTT siren platform."""
|
||||||
import copy
|
import copy
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -51,6 +52,7 @@ from .test_common import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message
|
from tests.common import async_fire_mqtt_message
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {siren.DOMAIN: {"name": "test", "command_topic": "test-topic"}}
|
mqtt.DOMAIN: {siren.DOMAIN: {"name": "test", "command_topic": "test-topic"}}
|
||||||
|
@ -80,7 +82,7 @@ async def async_turn_off(hass, entity_id=ENTITY_MATCH_ALL) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_via_topic(
|
async def test_controlling_state_via_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic."""
|
"""Test the controlling state via topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -117,7 +119,7 @@ async def test_controlling_state_via_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_and_optimistic(
|
async def test_sending_mqtt_commands_and_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending MQTT commands in optimistic mode."""
|
"""Test the sending MQTT commands in optimistic mode."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -161,7 +163,9 @@ async def test_sending_mqtt_commands_and_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_via_topic_and_json_message(
|
async def test_controlling_state_via_topic_and_json_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic and JSON message."""
|
"""Test the controlling state via topic and JSON message."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -202,7 +206,9 @@ async def test_controlling_state_via_topic_and_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_and_attributes_with_json_message_without_template(
|
async def test_controlling_state_and_attributes_with_json_message_without_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic and JSON message without a value template."""
|
"""Test the controlling state via topic and JSON message without a value template."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -282,7 +288,7 @@ async def test_controlling_state_and_attributes_with_json_message_without_templa
|
||||||
|
|
||||||
|
|
||||||
async def test_filtering_not_supported_attributes_optimistic(
|
async def test_filtering_not_supported_attributes_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting attributes with support flags optimistic."""
|
"""Test setting attributes with support flags optimistic."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -367,7 +373,7 @@ async def test_filtering_not_supported_attributes_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_filtering_not_supported_attributes_via_state(
|
async def test_filtering_not_supported_attributes_via_state(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting attributes with support flags via state."""
|
"""Test setting attributes with support flags via state."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -446,7 +452,7 @@ async def test_filtering_not_supported_attributes_via_state(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -455,7 +461,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -464,7 +470,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -491,7 +497,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -518,7 +524,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_state_payload(
|
async def test_custom_state_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the state payload."""
|
"""Test the state payload."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -557,7 +563,7 @@ async def test_custom_state_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -566,7 +572,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -575,7 +581,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -584,7 +590,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -597,7 +605,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -610,7 +620,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -648,7 +660,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_siren(
|
async def test_discovery_removal_siren(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered siren."""
|
"""Test removal of discovered siren."""
|
||||||
data = (
|
data = (
|
||||||
|
@ -662,7 +676,9 @@ async def test_discovery_removal_siren(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_siren_topic_template(
|
async def test_discovery_update_siren_topic_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered siren."""
|
"""Test update of discovered siren."""
|
||||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][siren.DOMAIN])
|
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][siren.DOMAIN])
|
||||||
|
@ -699,7 +715,9 @@ async def test_discovery_update_siren_topic_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_siren_template(
|
async def test_discovery_update_siren_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered siren."""
|
"""Test update of discovered siren."""
|
||||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][siren.DOMAIN])
|
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][siren.DOMAIN])
|
||||||
|
@ -734,7 +752,9 @@ async def test_discovery_update_siren_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_command_templates(
|
async def test_command_templates(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test siren with command templates optimistic."""
|
"""Test siren with command templates optimistic."""
|
||||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][siren.DOMAIN])
|
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][siren.DOMAIN])
|
||||||
|
@ -816,7 +836,9 @@ async def test_command_templates(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_siren(
|
async def test_discovery_update_unchanged_siren(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered siren."""
|
"""Test update of discovered siren."""
|
||||||
data1 = (
|
data1 = (
|
||||||
|
@ -840,7 +862,9 @@ async def test_discovery_update_unchanged_siren(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer" }'
|
data1 = '{ "name": "Beer" }'
|
||||||
|
@ -855,7 +879,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT siren device registry integration."""
|
"""Test MQTT siren device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -864,7 +888,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT siren device registry integration."""
|
"""Test MQTT siren device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -873,7 +897,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -882,7 +906,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -891,7 +915,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
await help_test_entity_id_update_subscriptions(
|
await help_test_entity_id_update_subscriptions(
|
||||||
|
@ -900,7 +924,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -909,7 +933,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
await help_test_entity_debug_info_message(
|
await help_test_entity_debug_info_message(
|
||||||
|
@ -943,8 +967,8 @@ async def test_entity_debug_info_message(
|
||||||
)
|
)
|
||||||
async def test_publishing_with_custom_encoding(
|
async def test_publishing_with_custom_encoding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
service,
|
service,
|
||||||
topic,
|
topic,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -971,7 +995,10 @@ async def test_publishing_with_custom_encoding(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = siren.DOMAIN
|
domain = siren.DOMAIN
|
||||||
|
@ -989,8 +1016,8 @@ async def test_reloadable(
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
@ -1018,7 +1045,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = siren.DOMAIN
|
domain = siren.DOMAIN
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""The tests for the State vacuum Mqtt platform."""
|
"""The tests for the State vacuum Mqtt platform."""
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import json
|
import json
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -61,6 +62,7 @@ from .test_common import (
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message
|
from tests.common import async_fire_mqtt_message
|
||||||
from tests.components.vacuum import common
|
from tests.components.vacuum import common
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
COMMAND_TOPIC = "vacuum/command"
|
COMMAND_TOPIC = "vacuum/command"
|
||||||
SEND_COMMAND_TOPIC = "vacuum/send_command"
|
SEND_COMMAND_TOPIC = "vacuum/send_command"
|
||||||
|
@ -91,7 +93,7 @@ def vacuum_platform_only():
|
||||||
|
|
||||||
|
|
||||||
async def test_default_supported_features(
|
async def test_default_supported_features(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that the correct supported features."""
|
"""Test that the correct supported features."""
|
||||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
||||||
|
@ -105,7 +107,7 @@ async def test_default_supported_features(
|
||||||
|
|
||||||
|
|
||||||
async def test_all_commands(
|
async def test_all_commands(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test simple commands send to the vacuum."""
|
"""Test simple commands send to the vacuum."""
|
||||||
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
||||||
|
@ -181,7 +183,7 @@ async def test_all_commands(
|
||||||
|
|
||||||
|
|
||||||
async def test_commands_without_supported_features(
|
async def test_commands_without_supported_features(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test commands which are not supported by the vacuum."""
|
"""Test commands which are not supported by the vacuum."""
|
||||||
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
||||||
|
@ -290,7 +292,7 @@ async def test_status(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) ->
|
||||||
|
|
||||||
|
|
||||||
async def test_no_fan_vacuum(
|
async def test_no_fan_vacuum(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test status updates from the vacuum when fan is not supported."""
|
"""Test status updates from the vacuum when fan is not supported."""
|
||||||
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
||||||
|
@ -346,7 +348,7 @@ async def test_no_fan_vacuum(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_status_invalid_json(
|
async def test_status_invalid_json(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test to make sure nothing breaks if the vacuum sends bad JSON."""
|
"""Test to make sure nothing breaks if the vacuum sends bad JSON."""
|
||||||
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
config = deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][vacuum.DOMAIN])
|
||||||
|
@ -366,7 +368,7 @@ async def test_status_invalid_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -375,7 +377,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -384,7 +386,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_payload(
|
await help_test_default_availability_payload(
|
||||||
|
@ -393,7 +395,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
await help_test_custom_availability_payload(
|
await help_test_custom_availability_payload(
|
||||||
|
@ -402,7 +404,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -411,7 +413,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -424,7 +426,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -433,7 +435,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -446,7 +450,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -459,7 +465,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -497,7 +505,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_vacuum(
|
async def test_discovery_removal_vacuum(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered vacuum."""
|
"""Test removal of discovered vacuum."""
|
||||||
data = '{ "schema": "state", "name": "test", "command_topic": "test_topic"}'
|
data = '{ "schema": "state", "name": "test", "command_topic": "test_topic"}'
|
||||||
|
@ -507,7 +517,9 @@ async def test_discovery_removal_vacuum(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_vacuum(
|
async def test_discovery_update_vacuum(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered vacuum."""
|
"""Test update of discovered vacuum."""
|
||||||
config1 = {"schema": "state", "name": "Beer", "command_topic": "test_topic"}
|
config1 = {"schema": "state", "name": "Beer", "command_topic": "test_topic"}
|
||||||
|
@ -518,7 +530,9 @@ async def test_discovery_update_vacuum(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_vacuum(
|
async def test_discovery_update_unchanged_vacuum(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered vacuum."""
|
"""Test update of discovered vacuum."""
|
||||||
data1 = '{ "schema": "state", "name": "Beer", "command_topic": "test_topic"}'
|
data1 = '{ "schema": "state", "name": "Beer", "command_topic": "test_topic"}'
|
||||||
|
@ -537,7 +551,9 @@ async def test_discovery_update_unchanged_vacuum(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "schema": "state", "name": "Beer", "command_topic": "test_topic#"}'
|
data1 = '{ "schema": "state", "name": "Beer", "command_topic": "test_topic#"}'
|
||||||
|
@ -548,7 +564,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT vacuum device registry integration."""
|
"""Test MQTT vacuum device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -557,7 +573,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT vacuum device registry integration."""
|
"""Test MQTT vacuum device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -566,7 +582,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -575,7 +591,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -584,7 +600,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
await help_test_entity_id_update_subscriptions(
|
await help_test_entity_id_update_subscriptions(
|
||||||
|
@ -593,7 +609,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -602,7 +618,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
await help_test_entity_debug_info_message(
|
await help_test_entity_debug_info_message(
|
||||||
|
@ -658,8 +674,8 @@ async def test_entity_debug_info_message(
|
||||||
)
|
)
|
||||||
async def test_publishing_with_custom_encoding(
|
async def test_publishing_with_custom_encoding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
service,
|
service,
|
||||||
topic,
|
topic,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -697,7 +713,10 @@ async def test_publishing_with_custom_encoding(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = vacuum.DOMAIN
|
domain = vacuum.DOMAIN
|
||||||
|
@ -726,8 +745,8 @@ async def test_reloadable(
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
|
|
@ -11,6 +11,7 @@ from homeassistant.components.mqtt.subscription import (
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message
|
from tests.common import async_fire_mqtt_message
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
|
@ -21,7 +22,9 @@ def no_platforms():
|
||||||
|
|
||||||
|
|
||||||
async def test_subscribe_topics(
|
async def test_subscribe_topics(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test subscription to topics."""
|
"""Test subscription to topics."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -72,7 +75,9 @@ async def test_subscribe_topics(
|
||||||
|
|
||||||
|
|
||||||
async def test_modify_topics(
|
async def test_modify_topics(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test modification of topics."""
|
"""Test modification of topics."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -137,7 +142,9 @@ async def test_modify_topics(
|
||||||
|
|
||||||
|
|
||||||
async def test_qos_encoding_default(
|
async def test_qos_encoding_default(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test default qos and encoding."""
|
"""Test default qos and encoding."""
|
||||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -157,7 +164,9 @@ async def test_qos_encoding_default(
|
||||||
|
|
||||||
|
|
||||||
async def test_qos_encoding_custom(
|
async def test_qos_encoding_custom(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test custom qos and encoding."""
|
"""Test custom qos and encoding."""
|
||||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -184,7 +193,9 @@ async def test_qos_encoding_custom(
|
||||||
|
|
||||||
|
|
||||||
async def test_no_change(
|
async def test_no_change(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test subscription to topics without change."""
|
"""Test subscription to topics without change."""
|
||||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""The tests for the MQTT switch platform."""
|
"""The tests for the MQTT switch platform."""
|
||||||
import copy
|
import copy
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -48,6 +49,7 @@ from .test_common import (
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message, mock_restore_cache
|
from tests.common import async_fire_mqtt_message, mock_restore_cache
|
||||||
from tests.components.switch import common
|
from tests.components.switch import common
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {switch.DOMAIN: {"name": "test", "command_topic": "test-topic"}}
|
mqtt.DOMAIN: {switch.DOMAIN: {"name": "test", "command_topic": "test-topic"}}
|
||||||
|
@ -62,7 +64,7 @@ def switch_platform_only():
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_via_topic(
|
async def test_controlling_state_via_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic."""
|
"""Test the controlling state via topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -106,7 +108,7 @@ async def test_controlling_state_via_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_and_optimistic(
|
async def test_sending_mqtt_commands_and_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending MQTT commands in optimistic mode."""
|
"""Test the sending MQTT commands in optimistic mode."""
|
||||||
fake_state = State("switch.test", "on")
|
fake_state = State("switch.test", "on")
|
||||||
|
@ -153,7 +155,7 @@ async def test_sending_mqtt_commands_and_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_inital_state_and_optimistic(
|
async def test_sending_inital_state_and_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the initial state in optimistic mode."""
|
"""Test the initial state in optimistic mode."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -177,7 +179,7 @@ async def test_sending_inital_state_and_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_via_topic_and_json_message(
|
async def test_controlling_state_via_topic_and_json_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic and JSON message."""
|
"""Test the controlling state via topic and JSON message."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -219,7 +221,7 @@ async def test_controlling_state_via_topic_and_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -228,7 +230,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -237,7 +239,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -264,7 +266,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -291,7 +293,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_state_payload(
|
async def test_custom_state_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the state payload."""
|
"""Test the state payload."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -330,7 +332,7 @@ async def test_custom_state_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -339,7 +341,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -348,7 +350,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -357,7 +359,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -370,7 +374,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -383,7 +389,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -421,7 +429,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_switch(
|
async def test_discovery_removal_switch(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered switch."""
|
"""Test removal of discovered switch."""
|
||||||
data = (
|
data = (
|
||||||
|
@ -435,7 +445,9 @@ async def test_discovery_removal_switch(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_switch_topic_template(
|
async def test_discovery_update_switch_topic_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered switch."""
|
"""Test update of discovered switch."""
|
||||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][switch.DOMAIN])
|
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][switch.DOMAIN])
|
||||||
|
@ -472,7 +484,9 @@ async def test_discovery_update_switch_topic_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_switch_template(
|
async def test_discovery_update_switch_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered switch."""
|
"""Test update of discovered switch."""
|
||||||
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][switch.DOMAIN])
|
config1 = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][switch.DOMAIN])
|
||||||
|
@ -507,7 +521,9 @@ async def test_discovery_update_switch_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_switch(
|
async def test_discovery_update_unchanged_switch(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered switch."""
|
"""Test update of discovered switch."""
|
||||||
data1 = (
|
data1 = (
|
||||||
|
@ -531,7 +547,9 @@ async def test_discovery_update_unchanged_switch(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer" }'
|
data1 = '{ "name": "Beer" }'
|
||||||
|
@ -546,7 +564,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT switch device registry integration."""
|
"""Test MQTT switch device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -555,7 +573,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT switch device registry integration."""
|
"""Test MQTT switch device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -564,7 +582,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -573,7 +591,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -582,7 +600,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
await help_test_entity_id_update_subscriptions(
|
await help_test_entity_id_update_subscriptions(
|
||||||
|
@ -591,7 +609,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -600,7 +618,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
await help_test_entity_debug_info_message(
|
await help_test_entity_debug_info_message(
|
||||||
|
@ -633,8 +651,8 @@ async def test_entity_debug_info_message(
|
||||||
)
|
)
|
||||||
async def test_publishing_with_custom_encoding(
|
async def test_publishing_with_custom_encoding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
service,
|
service,
|
||||||
topic,
|
topic,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -660,7 +678,10 @@ async def test_publishing_with_custom_encoding(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = switch.DOMAIN
|
domain = switch.DOMAIN
|
||||||
|
@ -678,8 +699,8 @@ async def test_reloadable(
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
@ -707,7 +728,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = switch.DOMAIN
|
domain = switch.DOMAIN
|
||||||
|
|
|
@ -20,6 +20,7 @@ from tests.common import (
|
||||||
async_fire_mqtt_message,
|
async_fire_mqtt_message,
|
||||||
async_get_device_automations,
|
async_get_device_automations,
|
||||||
)
|
)
|
||||||
|
from tests.typing import MqttMockHAClient, MqttMockHAClientGenerator, WebSocketGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG_DEVICE = {
|
DEFAULT_CONFIG_DEVICE = {
|
||||||
"device": {"identifiers": ["0AFFD2"]},
|
"device": {"identifiers": ["0AFFD2"]},
|
||||||
|
@ -63,7 +64,7 @@ def tag_mock():
|
||||||
async def test_discover_bad_tag(
|
async def test_discover_bad_tag(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry,
|
||||||
mqtt_mock_entry_no_yaml_config,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
tag_mock,
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test bad discovery message."""
|
"""Test bad discovery message."""
|
||||||
|
@ -88,7 +89,10 @@ async def test_discover_bad_tag(
|
||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_mqtt_message_with_device(
|
async def test_if_fires_on_mqtt_message_with_device(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config, tag_mock
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tag scanning, with device."""
|
"""Test tag scanning, with device."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -105,7 +109,10 @@ async def test_if_fires_on_mqtt_message_with_device(
|
||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_mqtt_message_without_device(
|
async def test_if_fires_on_mqtt_message_without_device(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, tag_mock
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tag scanning, without device."""
|
"""Test tag scanning, without device."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -121,7 +128,10 @@ async def test_if_fires_on_mqtt_message_without_device(
|
||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_mqtt_message_with_template(
|
async def test_if_fires_on_mqtt_message_with_template(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config, tag_mock
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tag scanning, with device."""
|
"""Test tag scanning, with device."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -138,7 +148,9 @@ async def test_if_fires_on_mqtt_message_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_strip_tag_id(
|
async def test_strip_tag_id(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, tag_mock
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test strip whitespace from tag_id."""
|
"""Test strip whitespace from tag_id."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -154,7 +166,10 @@ async def test_strip_tag_id(
|
||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_mqtt_message_after_update_with_device(
|
async def test_if_fires_on_mqtt_message_after_update_with_device(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config, tag_mock
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tag scanning after update."""
|
"""Test tag scanning after update."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -201,7 +216,9 @@ async def test_if_fires_on_mqtt_message_after_update_with_device(
|
||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_mqtt_message_after_update_without_device(
|
async def test_if_fires_on_mqtt_message_after_update_without_device(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, tag_mock
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tag scanning after update."""
|
"""Test tag scanning after update."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -245,7 +262,10 @@ async def test_if_fires_on_mqtt_message_after_update_without_device(
|
||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_mqtt_message_after_update_with_template(
|
async def test_if_fires_on_mqtt_message_after_update_with_template(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config, tag_mock
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tag scanning after update."""
|
"""Test tag scanning after update."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -291,7 +311,9 @@ async def test_if_fires_on_mqtt_message_after_update_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_no_resubscribe_same_topic(
|
async def test_no_resubscribe_same_topic(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test subscription to topics without change."""
|
"""Test subscription to topics without change."""
|
||||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -308,7 +330,10 @@ async def test_no_resubscribe_same_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_not_fires_on_mqtt_message_after_remove_by_mqtt_with_device(
|
async def test_not_fires_on_mqtt_message_after_remove_by_mqtt_with_device(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config, tag_mock
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tag scanning after removal."""
|
"""Test tag scanning after removal."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -342,7 +367,9 @@ async def test_not_fires_on_mqtt_message_after_remove_by_mqtt_with_device(
|
||||||
|
|
||||||
|
|
||||||
async def test_not_fires_on_mqtt_message_after_remove_by_mqtt_without_device(
|
async def test_not_fires_on_mqtt_message_after_remove_by_mqtt_without_device(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, tag_mock
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tag scanning not firing after removal."""
|
"""Test tag scanning not firing after removal."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -376,9 +403,9 @@ async def test_not_fires_on_mqtt_message_after_remove_by_mqtt_without_device(
|
||||||
|
|
||||||
async def test_not_fires_on_mqtt_message_after_remove_from_registry(
|
async def test_not_fires_on_mqtt_message_after_remove_from_registry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client,
|
hass_ws_client: WebSocketGenerator,
|
||||||
device_registry,
|
device_registry,
|
||||||
mqtt_mock_entry_no_yaml_config,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
tag_mock,
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tag scanning after removal."""
|
"""Test tag scanning after removal."""
|
||||||
|
@ -418,7 +445,7 @@ async def test_not_fires_on_mqtt_message_after_remove_from_registry(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT device registry integration."""
|
"""Test MQTT device registry integration."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -453,7 +480,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT device registry integration."""
|
"""Test MQTT device registry integration."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -486,7 +513,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -524,9 +551,9 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
async def test_cleanup_tag(
|
async def test_cleanup_tag(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client,
|
hass_ws_client: WebSocketGenerator,
|
||||||
device_registry,
|
device_registry,
|
||||||
mqtt_mock_entry_no_yaml_config,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test tag discovery topic is cleaned when device is removed from registry."""
|
"""Test tag discovery topic is cleaned when device is removed from registry."""
|
||||||
assert await async_setup_component(hass, "config", {})
|
assert await async_setup_component(hass, "config", {})
|
||||||
|
@ -607,7 +634,9 @@ async def test_cleanup_tag(
|
||||||
|
|
||||||
|
|
||||||
async def test_cleanup_device(
|
async def test_cleanup_device(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal from device registry when tag is removed."""
|
"""Test removal from device registry when tag is removed."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
|
@ -635,7 +664,7 @@ async def test_cleanup_device(
|
||||||
async def test_cleanup_device_several_tags(
|
async def test_cleanup_device_several_tags(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry,
|
||||||
mqtt_mock_entry_no_yaml_config,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
tag_mock,
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal from device registry when the last tag is removed."""
|
"""Test removal from device registry when the last tag is removed."""
|
||||||
|
@ -681,7 +710,9 @@ async def test_cleanup_device_several_tags(
|
||||||
|
|
||||||
|
|
||||||
async def test_cleanup_device_with_entity_and_trigger_1(
|
async def test_cleanup_device_with_entity_and_trigger_1(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal from device registry for device with tag, entity and trigger.
|
"""Test removal from device registry for device with tag, entity and trigger.
|
||||||
|
|
||||||
|
@ -746,7 +777,9 @@ async def test_cleanup_device_with_entity_and_trigger_1(
|
||||||
|
|
||||||
|
|
||||||
async def test_cleanup_device_with_entity2(
|
async def test_cleanup_device_with_entity2(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock_entry_no_yaml_config
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal from device registry for device with tag, entity and trigger.
|
"""Test removal from device registry for device with tag, entity and trigger.
|
||||||
|
|
||||||
|
@ -813,7 +846,7 @@ async def test_cleanup_device_with_entity2(
|
||||||
@pytest.mark.xfail(raises=MultipleInvalid)
|
@pytest.mark.xfail(raises=MultipleInvalid)
|
||||||
async def test_update_with_bad_config_not_breaks_discovery(
|
async def test_update_with_bad_config_not_breaks_discovery(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_no_yaml_config,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
tag_mock,
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test a bad update does not break discovery."""
|
"""Test a bad update does not break discovery."""
|
||||||
|
@ -855,7 +888,11 @@ async def test_update_with_bad_config_not_breaks_discovery(
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
async def test_unload_entry(
|
||||||
hass: HomeAssistant, device_registry, mqtt_mock, tag_mock, tmp_path
|
hass: HomeAssistant,
|
||||||
|
device_registry,
|
||||||
|
mqtt_mock: MqttMockHAClient,
|
||||||
|
tag_mock,
|
||||||
|
tmp_path,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test unloading the MQTT entry."""
|
"""Test unloading the MQTT entry."""
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""The tests for the MQTT text platform."""
|
"""The tests for the MQTT text platform."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -46,6 +47,7 @@ from .test_common import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message
|
from tests.common import async_fire_mqtt_message
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {text.DOMAIN: {"name": "test", "command_topic": "test-topic"}}
|
mqtt.DOMAIN: {text.DOMAIN: {"name": "test", "command_topic": "test-topic"}}
|
||||||
|
@ -72,7 +74,7 @@ async def async_set_value(
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_state_via_topic(
|
async def test_controlling_state_via_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the controlling state via topic."""
|
"""Test the controlling state via topic."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -114,7 +116,7 @@ async def test_controlling_state_via_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_controlling_validation_state_via_topic(
|
async def test_controlling_validation_state_via_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the validation of a received state."""
|
"""Test the validation of a received state."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -211,7 +213,7 @@ async def test_attribute_validation_max_not_greater_then_max_state_length(
|
||||||
|
|
||||||
|
|
||||||
async def test_sending_mqtt_commands_and_optimistic(
|
async def test_sending_mqtt_commands_and_optimistic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sending MQTT commands in optimistic mode."""
|
"""Test the sending MQTT commands in optimistic mode."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -254,7 +256,7 @@ async def test_sending_mqtt_commands_and_optimistic(
|
||||||
|
|
||||||
|
|
||||||
async def test_set_text_validation(
|
async def test_set_text_validation(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the initial state in optimistic mode."""
|
"""Test the initial state in optimistic mode."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -298,7 +300,7 @@ async def test_set_text_validation(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -307,7 +309,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -316,7 +318,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -341,7 +343,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
config = {
|
config = {
|
||||||
|
@ -366,7 +368,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -375,7 +377,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_blocked_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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
@ -384,7 +386,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -393,7 +395,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -406,7 +410,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -419,7 +425,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -457,7 +465,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_text(
|
async def test_discovery_removal_text(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered text entity."""
|
"""Test removal of discovered text entity."""
|
||||||
data = (
|
data = (
|
||||||
|
@ -471,7 +481,9 @@ async def test_discovery_removal_text(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_text_update(
|
async def test_discovery_text_update(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered text entity."""
|
"""Test update of discovered text entity."""
|
||||||
config1 = {
|
config1 = {
|
||||||
|
@ -491,7 +503,9 @@ async def test_discovery_text_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_update(
|
async def test_discovery_update_unchanged_update(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered update."""
|
"""Test update of discovered update."""
|
||||||
data1 = '{ "name": "Beer", "state_topic": "text-topic", "command_topic": "command-topic"}'
|
data1 = '{ "name": "Beer", "state_topic": "text-topic", "command_topic": "command-topic"}'
|
||||||
|
@ -509,7 +523,9 @@ async def test_discovery_update_unchanged_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_text(
|
async def test_discovery_update_text(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered text entity."""
|
"""Test update of discovered text entity."""
|
||||||
config1 = {"name": "Beer", "command_topic": "cmd-topic1"}
|
config1 = {"name": "Beer", "command_topic": "cmd-topic1"}
|
||||||
|
@ -520,7 +536,9 @@ async def test_discovery_update_text(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_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:
|
) -> None:
|
||||||
"""Test update of discovered text entity."""
|
"""Test update of discovered text entity."""
|
||||||
data1 = '{ "name": "Beer", "command_topic": "cmd-topic" }'
|
data1 = '{ "name": "Beer", "command_topic": "cmd-topic" }'
|
||||||
|
@ -539,7 +557,9 @@ async def test_discovery_update_unchanged_climate(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer" }'
|
data1 = '{ "name": "Beer" }'
|
||||||
|
@ -554,7 +574,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT text device registry integration."""
|
"""Test MQTT text device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -563,7 +583,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT text device registry integration."""
|
"""Test MQTT text device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -572,7 +592,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -581,7 +601,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -590,7 +610,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_subscriptions(
|
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:
|
) -> None:
|
||||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||||
await help_test_entity_id_update_subscriptions(
|
await help_test_entity_id_update_subscriptions(
|
||||||
|
@ -599,7 +619,7 @@ async def test_entity_id_update_subscriptions(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -608,7 +628,7 @@ async def test_entity_id_update_discovery_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_debug_info_message(
|
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:
|
) -> None:
|
||||||
"""Test MQTT debug info."""
|
"""Test MQTT debug info."""
|
||||||
await help_test_entity_debug_info_message(
|
await help_test_entity_debug_info_message(
|
||||||
|
@ -630,8 +650,8 @@ async def test_entity_debug_info_message(
|
||||||
)
|
)
|
||||||
async def test_publishing_with_custom_encoding(
|
async def test_publishing_with_custom_encoding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
service,
|
service,
|
||||||
topic,
|
topic,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -657,7 +677,10 @@ async def test_publishing_with_custom_encoding(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = text.DOMAIN
|
domain = text.DOMAIN
|
||||||
|
@ -675,8 +698,8 @@ async def test_reloadable(
|
||||||
)
|
)
|
||||||
async def test_encoding_subscribable_topics(
|
async def test_encoding_subscribable_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry_with_yaml_config,
|
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
||||||
caplog,
|
caplog: pytest.LogCaptureFixture,
|
||||||
topic,
|
topic,
|
||||||
value,
|
value,
|
||||||
attribute,
|
attribute,
|
||||||
|
@ -704,7 +727,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = text.DOMAIN
|
domain = text.DOMAIN
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""The tests for mqtt update component."""
|
"""The tests for mqtt update component."""
|
||||||
import json
|
import json
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -42,6 +43,7 @@ from .test_common import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message
|
from tests.common import async_fire_mqtt_message
|
||||||
|
from tests.typing import MqttMockHAClientGenerator
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
@ -64,7 +66,7 @@ def update_platform_only():
|
||||||
|
|
||||||
|
|
||||||
async def test_run_update_setup(
|
async def test_run_update_setup(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that it fetches the given payload."""
|
"""Test that it fetches the given payload."""
|
||||||
installed_version_topic = "test/installed-version"
|
installed_version_topic = "test/installed-version"
|
||||||
|
@ -114,7 +116,7 @@ async def test_run_update_setup(
|
||||||
|
|
||||||
|
|
||||||
async def test_run_update_setup_float(
|
async def test_run_update_setup_float(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that it fetches the given payload when the version is parsable as a number."""
|
"""Test that it fetches the given payload when the version is parsable as a number."""
|
||||||
installed_version_topic = "test/installed-version"
|
installed_version_topic = "test/installed-version"
|
||||||
|
@ -164,7 +166,7 @@ async def test_run_update_setup_float(
|
||||||
|
|
||||||
|
|
||||||
async def test_value_template(
|
async def test_value_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that it fetches the given payload with a template."""
|
"""Test that it fetches the given payload with a template."""
|
||||||
installed_version_topic = "test/installed-version"
|
installed_version_topic = "test/installed-version"
|
||||||
|
@ -212,7 +214,7 @@ async def test_value_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_value_template_float(
|
async def test_value_template_float(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that it fetches the given payload with a template when the version is parsable as a number."""
|
"""Test that it fetches the given payload with a template when the version is parsable as a number."""
|
||||||
installed_version_topic = "test/installed-version"
|
installed_version_topic = "test/installed-version"
|
||||||
|
@ -260,7 +262,7 @@ async def test_value_template_float(
|
||||||
|
|
||||||
|
|
||||||
async def test_empty_json_state_message(
|
async def test_empty_json_state_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test an empty JSON payload."""
|
"""Test an empty JSON payload."""
|
||||||
state_topic = "test/state-topic"
|
state_topic = "test/state-topic"
|
||||||
|
@ -288,7 +290,7 @@ async def test_empty_json_state_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_json_state_message(
|
async def test_json_state_message(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test whether it fetches data from a JSON payload."""
|
"""Test whether it fetches data from a JSON payload."""
|
||||||
state_topic = "test/state-topic"
|
state_topic = "test/state-topic"
|
||||||
|
@ -344,7 +346,7 @@ async def test_json_state_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_json_state_message_with_template(
|
async def test_json_state_message_with_template(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test whether it fetches data from a JSON payload with template."""
|
"""Test whether it fetches data from a JSON payload with template."""
|
||||||
state_topic = "test/state-topic"
|
state_topic = "test/state-topic"
|
||||||
|
@ -384,7 +386,7 @@ async def test_json_state_message_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_run_install_service(
|
async def test_run_install_service(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that install service works."""
|
"""Test that install service works."""
|
||||||
installed_version_topic = "test/installed-version"
|
installed_version_topic = "test/installed-version"
|
||||||
|
@ -428,7 +430,7 @@ async def test_run_install_service(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_when_connection_lost(
|
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:
|
) -> None:
|
||||||
"""Test availability after MQTT disconnection."""
|
"""Test availability after MQTT disconnection."""
|
||||||
await help_test_availability_when_connection_lost(
|
await help_test_availability_when_connection_lost(
|
||||||
|
@ -437,7 +439,7 @@ async def test_availability_when_connection_lost(
|
||||||
|
|
||||||
|
|
||||||
async def test_availability_without_topic(
|
async def test_availability_without_topic(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability without defined availability topic."""
|
"""Test availability without defined availability topic."""
|
||||||
await help_test_availability_without_topic(
|
await help_test_availability_without_topic(
|
||||||
|
@ -446,7 +448,7 @@ async def test_availability_without_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_payload(
|
async def test_default_availability_payload(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
await help_test_default_availability_payload(
|
await help_test_default_availability_payload(
|
||||||
|
@ -455,7 +457,7 @@ async def test_default_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_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:
|
) -> None:
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
await help_test_custom_availability_payload(
|
await help_test_custom_availability_payload(
|
||||||
|
@ -464,7 +466,7 @@ async def test_custom_availability_payload(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_via_mqtt_json_message(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_via_mqtt_json_message(
|
await help_test_setting_attribute_via_mqtt_json_message(
|
||||||
|
@ -473,7 +475,7 @@ async def test_setting_attribute_via_mqtt_json_message(
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(
|
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:
|
) -> None:
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
@ -482,7 +484,9 @@ async def test_setting_attribute_with_template(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_not_dict(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_not_dict(
|
await help_test_update_with_json_attrs_not_dict(
|
||||||
|
@ -495,7 +499,9 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
|
|
||||||
|
|
||||||
async def test_update_with_json_attrs_bad_json(
|
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:
|
) -> None:
|
||||||
"""Test attributes get extracted from a JSON result."""
|
"""Test attributes get extracted from a JSON result."""
|
||||||
await help_test_update_with_json_attrs_bad_json(
|
await help_test_update_with_json_attrs_bad_json(
|
||||||
|
@ -508,7 +514,9 @@ async def test_update_with_json_attrs_bad_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_attr(
|
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:
|
) -> None:
|
||||||
"""Test update of discovered MQTTAttributes."""
|
"""Test update of discovered MQTTAttributes."""
|
||||||
await help_test_discovery_update_attr(
|
await help_test_discovery_update_attr(
|
||||||
|
@ -546,7 +554,9 @@ async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_removal_update(
|
async def test_discovery_removal_update(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removal of discovered update."""
|
"""Test removal of discovered update."""
|
||||||
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][update.DOMAIN])
|
data = json.dumps(DEFAULT_CONFIG[mqtt.DOMAIN][update.DOMAIN])
|
||||||
|
@ -556,7 +566,9 @@ async def test_discovery_removal_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_update(
|
async def test_discovery_update_update(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered update."""
|
"""Test update of discovered update."""
|
||||||
config1 = {
|
config1 = {
|
||||||
|
@ -576,7 +588,9 @@ async def test_discovery_update_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_update_unchanged_update(
|
async def test_discovery_update_unchanged_update(
|
||||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config, caplog
|
hass: HomeAssistant,
|
||||||
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update of discovered update."""
|
"""Test update of discovered update."""
|
||||||
data1 = '{ "name": "Beer", "state_topic": "installed-topic", "latest_version_topic": "latest-topic"}'
|
data1 = '{ "name": "Beer", "state_topic": "installed-topic", "latest_version_topic": "latest-topic"}'
|
||||||
|
@ -595,7 +609,9 @@ async def test_discovery_update_unchanged_update(
|
||||||
|
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discovery_broken(
|
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:
|
) -> None:
|
||||||
"""Test handling of bad discovery message."""
|
"""Test handling of bad discovery message."""
|
||||||
data1 = '{ "name": "Beer" }'
|
data1 = '{ "name": "Beer" }'
|
||||||
|
@ -607,7 +623,7 @@ async def test_discovery_broken(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_connection(
|
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:
|
) -> None:
|
||||||
"""Test MQTT update device registry integration."""
|
"""Test MQTT update device registry integration."""
|
||||||
await help_test_entity_device_info_with_connection(
|
await help_test_entity_device_info_with_connection(
|
||||||
|
@ -616,7 +632,7 @@ async def test_entity_device_info_with_connection(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_with_identifier(
|
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:
|
) -> None:
|
||||||
"""Test MQTT update device registry integration."""
|
"""Test MQTT update device registry integration."""
|
||||||
await help_test_entity_device_info_with_identifier(
|
await help_test_entity_device_info_with_identifier(
|
||||||
|
@ -625,7 +641,7 @@ async def test_entity_device_info_with_identifier(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_update(
|
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:
|
) -> None:
|
||||||
"""Test device registry update."""
|
"""Test device registry update."""
|
||||||
await help_test_entity_device_info_update(
|
await help_test_entity_device_info_update(
|
||||||
|
@ -634,7 +650,7 @@ async def test_entity_device_info_update(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_device_info_remove(
|
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:
|
) -> None:
|
||||||
"""Test device registry remove."""
|
"""Test device registry remove."""
|
||||||
await help_test_entity_device_info_remove(
|
await help_test_entity_device_info_remove(
|
||||||
|
@ -643,7 +659,7 @@ async def test_entity_device_info_remove(
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_update_discovery_update(
|
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:
|
) -> None:
|
||||||
"""Test MQTT discovery update when entity_id is updated."""
|
"""Test MQTT discovery update when entity_id is updated."""
|
||||||
await help_test_entity_id_update_discovery_update(
|
await help_test_entity_id_update_discovery_update(
|
||||||
|
@ -659,7 +675,9 @@ async def test_setup_manual_entity_from_yaml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
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:
|
) -> None:
|
||||||
"""Test unloading the config entry."""
|
"""Test unloading the config entry."""
|
||||||
domain = update.DOMAIN
|
domain = update.DOMAIN
|
||||||
|
@ -670,7 +688,10 @@ async def test_unload_entry(
|
||||||
|
|
||||||
|
|
||||||
async def test_reloadable(
|
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:
|
) -> None:
|
||||||
"""Test reloading the MQTT platform."""
|
"""Test reloading the MQTT platform."""
|
||||||
domain = update.DOMAIN
|
domain = update.DOMAIN
|
||||||
|
|
Loading…
Add table
Reference in a new issue