Apply registry type hints on mqtt platform tests (#87758)
Apply registry fixture types on platform tests
This commit is contained in:
parent
678d1e367d
commit
bb174780b9
28 changed files with 188 additions and 97 deletions
|
@ -731,7 +731,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one alarm per unique_id."""
|
"""Test unique id option only creates one alarm per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -526,7 +526,9 @@ async def test_valid_device_class(
|
||||||
assert state.attributes.get("device_class") == "motion"
|
assert state.attributes.get("device_class") == "motion"
|
||||||
|
|
||||||
|
|
||||||
async def test_invalid_device_class(hass: HomeAssistant, caplog) -> None:
|
async def test_invalid_device_class(
|
||||||
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||||
|
) -> None:
|
||||||
"""Test the setting of an invalid sensor class."""
|
"""Test the setting of an invalid sensor class."""
|
||||||
assert not await async_setup_component(
|
assert not await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
|
@ -671,7 +673,9 @@ async def test_force_update_enabled(
|
||||||
assert len(events) == 2
|
assert len(events) == 2
|
||||||
|
|
||||||
|
|
||||||
async def test_off_delay(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_off_delay(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test off_delay option."""
|
"""Test off_delay option."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
|
@ -789,7 +793,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one sensor per unique_id."""
|
"""Test unique id option only creates one sensor per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -277,7 +277,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one button per unique_id."""
|
"""Test unique id option only creates one button per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -82,7 +82,7 @@ async def test_run_camera_setup(
|
||||||
|
|
||||||
async def test_run_camera_b64_encoded(
|
async def test_run_camera_b64_encoded(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator,
|
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."""
|
||||||
|
@ -266,7 +266,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one camera per unique_id."""
|
"""Test unique id option only creates one camera per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -122,7 +122,9 @@ async def test_setup_params(
|
||||||
assert state.attributes.get("max_humidity") == DEFAULT_MAX_HUMIDITY
|
assert state.attributes.get("max_humidity") == DEFAULT_MAX_HUMIDITY
|
||||||
|
|
||||||
|
|
||||||
async def test_preset_none_in_preset_modes(hass: HomeAssistant, caplog) -> None:
|
async def test_preset_none_in_preset_modes(
|
||||||
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||||
|
) -> None:
|
||||||
"""Test the preset mode payload reset configuration."""
|
"""Test the preset mode payload reset configuration."""
|
||||||
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][climate.DOMAIN])
|
config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN][climate.DOMAIN])
|
||||||
config["preset_modes"].append("none")
|
config["preset_modes"].append("none")
|
||||||
|
@ -489,7 +491,9 @@ async def test_set_swing_optimistic(
|
||||||
assert state.attributes.get("swing_mode") == "off"
|
assert state.attributes.get("swing_mode") == "off"
|
||||||
|
|
||||||
|
|
||||||
async def test_set_swing(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_set_swing(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test setting of new swing mode."""
|
"""Test setting of new swing mode."""
|
||||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -1017,7 +1021,9 @@ async def test_set_aux_pessimistic(
|
||||||
assert state.attributes.get("aux_heat") == "off"
|
assert state.attributes.get("aux_heat") == "off"
|
||||||
|
|
||||||
|
|
||||||
async def test_set_aux(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_set_aux(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test setting of the aux heating."""
|
"""Test setting of the aux heating."""
|
||||||
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
assert await async_setup_component(hass, mqtt.DOMAIN, DEFAULT_CONFIG)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -1510,7 +1516,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one climate per unique_id."""
|
"""Test unique id option only creates one climate per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -824,7 +824,9 @@ async def test_current_cover_position_inverted(
|
||||||
assert hass.states.get("cover.test").state == STATE_CLOSED
|
assert hass.states.get("cover.test").state == STATE_CLOSED
|
||||||
|
|
||||||
|
|
||||||
async def test_optimistic_position(hass: HomeAssistant, caplog) -> None:
|
async def test_optimistic_position(
|
||||||
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||||
|
) -> None:
|
||||||
"""Test optimistic position is not supported."""
|
"""Test optimistic position is not supported."""
|
||||||
assert not await async_setup_component(
|
assert not await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
|
@ -2567,7 +2569,9 @@ async def test_valid_device_class(
|
||||||
assert state.attributes.get("device_class") == "garage"
|
assert state.attributes.get("device_class") == "garage"
|
||||||
|
|
||||||
|
|
||||||
async def test_invalid_device_class(hass: HomeAssistant, caplog) -> None:
|
async def test_invalid_device_class(
|
||||||
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||||
|
) -> None:
|
||||||
"""Test the setting of an invalid device class."""
|
"""Test the setting of an invalid device class."""
|
||||||
assert not await async_setup_component(
|
assert not await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
|
@ -2661,7 +2665,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique_id option only creates one cover per id."""
|
"""Test unique_id option only creates one cover per id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
@ -3296,7 +3302,7 @@ async def test_position_via_position_topic_template_return_invalid_json(
|
||||||
|
|
||||||
|
|
||||||
async def test_set_position_topic_without_get_position_topic_error(
|
async def test_set_position_topic_without_get_position_topic_error(
|
||||||
hass: HomeAssistant, caplog
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test error when set_position_topic is used without position_topic."""
|
"""Test error when set_position_topic is used without position_topic."""
|
||||||
assert not await async_setup_component(
|
assert not await async_setup_component(
|
||||||
|
@ -3342,7 +3348,7 @@ async def test_value_template_without_state_topic_error(
|
||||||
|
|
||||||
|
|
||||||
async def test_position_template_without_position_topic_error(
|
async def test_position_template_without_position_topic_error(
|
||||||
hass: HomeAssistant, caplog
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test error when position_template is used and position_topic is missing."""
|
"""Test error when position_template is used and position_topic is missing."""
|
||||||
assert not await async_setup_component(
|
assert not await async_setup_component(
|
||||||
|
@ -3389,7 +3395,7 @@ async def test_set_position_template_without_set_position_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_command_template_without_tilt_command_topic(
|
async def test_tilt_command_template_without_tilt_command_topic(
|
||||||
hass: HomeAssistant, caplog
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test error when tilt_command_template is used and tilt_command_topic is missing."""
|
"""Test error when tilt_command_template is used and tilt_command_topic is missing."""
|
||||||
assert not await async_setup_component(
|
assert not await async_setup_component(
|
||||||
|
@ -3412,7 +3418,7 @@ async def test_tilt_command_template_without_tilt_command_topic(
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_status_template_without_tilt_status_topic_topic(
|
async def test_tilt_status_template_without_tilt_status_topic_topic(
|
||||||
hass: HomeAssistant, caplog
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test error when tilt_status_template is used and tilt_status_topic is missing."""
|
"""Test error when tilt_status_template is used and tilt_status_topic is missing."""
|
||||||
assert not await async_setup_component(
|
assert not await async_setup_component(
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""The tests for the MQTT device_tracker platform."""
|
"""The tests for the MQTT device_tracker platform."""
|
||||||
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -8,6 +7,7 @@ from homeassistant.components import device_tracker, mqtt
|
||||||
from homeassistant.components.mqtt.const import DOMAIN as MQTT_DOMAIN
|
from homeassistant.components.mqtt.const import DOMAIN as MQTT_DOMAIN
|
||||||
from homeassistant.const import STATE_HOME, STATE_NOT_HOME, STATE_UNKNOWN, Platform
|
from homeassistant.const import STATE_HOME, STATE_NOT_HOME, STATE_UNKNOWN, Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from .test_common import (
|
from .test_common import (
|
||||||
|
@ -225,8 +225,8 @@ 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: WebSocketGenerator,
|
hass_ws_client: WebSocketGenerator,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
entity_registry,
|
entity_registry: er.EntityRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
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."""
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""The tests for MQTT device triggers."""
|
"""The tests for MQTT device triggers."""
|
||||||
import json
|
import json
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -44,7 +45,7 @@ def binary_sensor_and_sensor_only():
|
||||||
|
|
||||||
async def test_get_triggers(
|
async def test_get_triggers(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
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."""
|
||||||
|
@ -80,7 +81,7 @@ async def test_get_triggers(
|
||||||
|
|
||||||
async def test_get_unknown_triggers(
|
async def test_get_unknown_triggers(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we don't get unknown triggers."""
|
"""Test we don't get unknown triggers."""
|
||||||
|
@ -127,7 +128,7 @@ async def test_get_unknown_triggers(
|
||||||
|
|
||||||
async def test_get_non_existing_triggers(
|
async def test_get_non_existing_triggers(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test getting non existing triggers."""
|
"""Test getting non existing triggers."""
|
||||||
|
@ -151,7 +152,7 @@ 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,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test bad discovery message."""
|
"""Test bad discovery message."""
|
||||||
|
@ -201,7 +202,7 @@ async def test_discover_bad_triggers(
|
||||||
|
|
||||||
async def test_update_remove_triggers(
|
async def test_update_remove_triggers(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test triggers can be updated and removed."""
|
"""Test triggers can be updated and removed."""
|
||||||
|
@ -270,7 +271,7 @@ async def test_update_remove_triggers(
|
||||||
|
|
||||||
async def test_if_fires_on_mqtt_message(
|
async def test_if_fires_on_mqtt_message(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
calls,
|
calls,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -349,7 +350,7 @@ 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,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
calls,
|
calls,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -430,7 +431,7 @@ 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,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
calls,
|
calls,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -517,7 +518,7 @@ 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,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
calls,
|
calls,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -597,7 +598,7 @@ 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,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test subscription to topics without change."""
|
"""Test subscription to topics without change."""
|
||||||
|
@ -644,7 +645,7 @@ 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,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
calls,
|
calls,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -710,7 +711,7 @@ 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: WebSocketGenerator,
|
hass_ws_client: WebSocketGenerator,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
calls,
|
calls,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -782,7 +783,7 @@ async def test_not_fires_on_mqtt_message_after_remove_from_registry(
|
||||||
|
|
||||||
async def test_attach_remove(
|
async def test_attach_remove(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attach and removal of trigger."""
|
"""Test attach and removal of trigger."""
|
||||||
|
@ -840,7 +841,7 @@ async def test_attach_remove(
|
||||||
|
|
||||||
async def test_attach_remove_late(
|
async def test_attach_remove_late(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attach and removal of trigger ."""
|
"""Test attach and removal of trigger ."""
|
||||||
|
@ -906,7 +907,7 @@ async def test_attach_remove_late(
|
||||||
|
|
||||||
async def test_attach_remove_late2(
|
async def test_attach_remove_late2(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attach and removal of trigger ."""
|
"""Test attach and removal of trigger ."""
|
||||||
|
@ -1081,7 +1082,7 @@ async def test_entity_device_info_update(
|
||||||
async def test_cleanup_trigger(
|
async def test_cleanup_trigger(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: WebSocketGenerator,
|
hass_ws_client: WebSocketGenerator,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
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."""
|
||||||
|
@ -1137,7 +1138,7 @@ async def test_cleanup_trigger(
|
||||||
|
|
||||||
async def test_cleanup_device(
|
async def test_cleanup_device(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
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."""
|
||||||
|
@ -1173,7 +1174,7 @@ async def test_cleanup_device(
|
||||||
|
|
||||||
async def test_cleanup_device_several_triggers(
|
async def test_cleanup_device_several_triggers(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
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."""
|
||||||
|
@ -1235,7 +1236,7 @@ async def test_cleanup_device_several_triggers(
|
||||||
|
|
||||||
async def test_cleanup_device_with_entity1(
|
async def test_cleanup_device_with_entity1(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
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.
|
||||||
|
@ -1296,7 +1297,7 @@ async def test_cleanup_device_with_entity1(
|
||||||
|
|
||||||
async def test_cleanup_device_with_entity2(
|
async def test_cleanup_device_with_entity2(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
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.
|
||||||
|
@ -1433,7 +1434,11 @@ async def test_trigger_debug_info(
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
async def test_unload_entry(
|
||||||
hass: HomeAssistant, calls, device_registry, mqtt_mock: MqttMockHAClient, tmp_path
|
hass: HomeAssistant,
|
||||||
|
calls,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
|
mqtt_mock: MqttMockHAClient,
|
||||||
|
tmp_path: Path,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test unloading the MQTT entry."""
|
"""Test unloading the MQTT entry."""
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""Test MQTT diagnostics."""
|
"""Test MQTT diagnostics."""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from unittest.mock import ANY, patch
|
from unittest.mock import ANY, patch
|
||||||
|
|
||||||
|
@ -8,13 +7,14 @@ import pytest
|
||||||
from homeassistant.components import mqtt
|
from homeassistant.components import mqtt
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers import device_registry as dr
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message
|
from tests.common import async_fire_mqtt_message
|
||||||
from tests.components.diagnostics import (
|
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
|
from tests.typing import ClientSessionGenerator, MqttMockHAClientGenerator
|
||||||
|
|
||||||
default_config = {
|
default_config = {
|
||||||
"birth_message": {},
|
"birth_message": {},
|
||||||
|
@ -49,8 +49,8 @@ def device_tracker_sensor_only():
|
||||||
|
|
||||||
async def test_entry_diagnostics(
|
async def test_entry_diagnostics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
hass_client,
|
hass_client: ClientSessionGenerator,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test config entry diagnostics."""
|
"""Test config entry diagnostics."""
|
||||||
|
@ -172,8 +172,8 @@ async def test_entry_diagnostics(
|
||||||
)
|
)
|
||||||
async def test_redact_diagnostics(
|
async def test_redact_diagnostics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
hass_client,
|
hass_client: ClientSessionGenerator,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test redacting diagnostics."""
|
"""Test redacting diagnostics."""
|
||||||
|
|
|
@ -24,8 +24,7 @@ from homeassistant.const import (
|
||||||
)
|
)
|
||||||
from homeassistant.core import Event, HomeAssistant, callback
|
from homeassistant.core import Event, HomeAssistant, callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
import homeassistant.helpers.device_registry as dr
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
import homeassistant.helpers.entity_registry as er
|
|
||||||
from homeassistant.helpers.service_info.mqtt import MqttServiceInfo
|
from homeassistant.helpers.service_info.mqtt import MqttServiceInfo
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,9 @@ def fan_platform_only():
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
async def test_fail_setup_if_no_command_topic(hass: HomeAssistant, caplog) -> None:
|
async def test_fail_setup_if_no_command_topic(
|
||||||
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||||
|
) -> None:
|
||||||
"""Test if command fails with command topic."""
|
"""Test if command fails with command topic."""
|
||||||
assert not await async_setup_component(
|
assert not await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
|
@ -1776,7 +1778,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique_id option only creates one fan per id."""
|
"""Test unique_id option only creates one fan per id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -131,7 +131,9 @@ async def async_set_humidity(
|
||||||
await hass.services.async_call(DOMAIN, SERVICE_SET_HUMIDITY, data, blocking=True)
|
await hass.services.async_call(DOMAIN, SERVICE_SET_HUMIDITY, data, blocking=True)
|
||||||
|
|
||||||
|
|
||||||
async def test_fail_setup_if_no_command_topic(hass: HomeAssistant, caplog) -> None:
|
async def test_fail_setup_if_no_command_topic(
|
||||||
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||||
|
) -> None:
|
||||||
"""Test if command fails with command topic."""
|
"""Test if command fails with command topic."""
|
||||||
assert not await async_setup_component(
|
assert not await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
|
@ -1133,7 +1135,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique_id option only creates one fan per id."""
|
"""Test unique_id option only creates one fan per id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -292,7 +292,9 @@ async def test_attributes_without_supported_features(
|
||||||
assert state.attributes.get(ATTR_FAN_SPEED_LIST) is None
|
assert state.attributes.get(ATTR_FAN_SPEED_LIST) is None
|
||||||
|
|
||||||
|
|
||||||
async def test_status(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_status(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> 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])
|
||||||
config[mqttvacuum.CONF_SUPPORTED_FEATURES] = services_to_strings(
|
config[mqttvacuum.CONF_SUPPORTED_FEATURES] = services_to_strings(
|
||||||
|
@ -742,7 +744,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one vacuum per unique_id."""
|
"""Test unique id option only creates one vacuum per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -243,7 +243,9 @@ def light_platform_only():
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
async def test_fail_setup_if_no_command_topic(hass: HomeAssistant, caplog) -> None:
|
async def test_fail_setup_if_no_command_topic(
|
||||||
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||||
|
) -> None:
|
||||||
"""Test if command fails with command topic."""
|
"""Test if command fails with command topic."""
|
||||||
assert not await async_setup_component(
|
assert not await async_setup_component(
|
||||||
hass, mqtt.DOMAIN, {mqtt.DOMAIN: {light.DOMAIN: {"name": "test"}}}
|
hass, mqtt.DOMAIN, {mqtt.DOMAIN: {light.DOMAIN: {"name": "test"}}}
|
||||||
|
@ -2074,7 +2076,9 @@ async def test_white_state_update(
|
||||||
assert state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
assert state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
||||||
|
|
||||||
|
|
||||||
async def test_effect(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_effect(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test effect."""
|
"""Test effect."""
|
||||||
config = {
|
config = {
|
||||||
light.DOMAIN: {
|
light.DOMAIN: {
|
||||||
|
@ -2223,7 +2227,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one light per unique_id."""
|
"""Test unique id option only creates one light per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -163,7 +163,9 @@ class JsonValidator:
|
||||||
return json.loads(self.jsondata) == json.loads(other)
|
return json.loads(self.jsondata) == json.loads(other)
|
||||||
|
|
||||||
|
|
||||||
async def test_fail_setup_if_no_command_topic(hass: HomeAssistant, caplog) -> None:
|
async def test_fail_setup_if_no_command_topic(
|
||||||
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||||
|
) -> None:
|
||||||
"""Test if setup fails with no command topic."""
|
"""Test if setup fails with no command topic."""
|
||||||
assert not await async_setup_component(
|
assert not await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
|
@ -1459,7 +1461,9 @@ async def test_sending_xy_color(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_effect(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_effect(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test for effect being sent when included."""
|
"""Test for effect being sent when included."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
|
@ -1985,7 +1989,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one light per unique_id."""
|
"""Test unique id option only creates one light per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -140,7 +140,9 @@ async def test_setup_fails(
|
||||||
assert "Invalid config for [mqtt]" in caplog.text
|
assert "Invalid config for [mqtt]" in caplog.text
|
||||||
|
|
||||||
|
|
||||||
async def test_rgb_light(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_rgb_light(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test RGB light flags brightness support."""
|
"""Test RGB light flags brightness support."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
|
@ -602,7 +604,9 @@ async def test_sending_mqtt_commands_non_optimistic_brightness_template(
|
||||||
state = hass.states.get("light.test")
|
state = hass.states.get("light.test")
|
||||||
|
|
||||||
|
|
||||||
async def test_effect(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_effect(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test effect sent over MQTT in optimistic mode."""
|
"""Test effect sent over MQTT in optimistic mode."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
|
@ -655,7 +659,9 @@ async def test_effect(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) ->
|
||||||
assert state.attributes.get("effect") == "colorloop"
|
assert state.attributes.get("effect") == "colorloop"
|
||||||
|
|
||||||
|
|
||||||
async def test_flash(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_flash(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test flash sent over MQTT in optimistic mode."""
|
"""Test flash sent over MQTT in optimistic mode."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
|
@ -957,7 +963,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one light per unique_id."""
|
"""Test unique id option only creates one light per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -760,7 +760,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one lock per unique_id."""
|
"""Test unique id option only creates one lock per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
@ -1010,7 +1012,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: pytest.LogCaptureFixture, tmp_path
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, tmp_path: Path
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setup manual configured MQTT entity."""
|
"""Test setup manual configured MQTT entity."""
|
||||||
platform = lock.DOMAIN
|
platform = lock.DOMAIN
|
||||||
|
|
|
@ -558,7 +558,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one number per unique_id."""
|
"""Test unique id option only creates one number per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
@ -756,7 +758,9 @@ async def test_min_max_step_attributes(
|
||||||
assert state.attributes.get(ATTR_STEP) == 20
|
assert state.attributes.get(ATTR_STEP) == 20
|
||||||
|
|
||||||
|
|
||||||
async def test_invalid_min_max_attributes(hass: HomeAssistant, caplog) -> None:
|
async def test_invalid_min_max_attributes(
|
||||||
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||||
|
) -> None:
|
||||||
"""Test invalid min/max attributes."""
|
"""Test invalid min/max attributes."""
|
||||||
topic = "test/number"
|
topic = "test/number"
|
||||||
assert not await async_setup_component(
|
assert not await async_setup_component(
|
||||||
|
|
|
@ -148,7 +148,9 @@ async def test_custom_availability_payload(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one scene per unique_id."""
|
"""Test unique id option only creates one scene per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -435,7 +435,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one select per unique_id."""
|
"""Test unique id option only creates one select per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -706,7 +706,9 @@ async def test_default_availability_list_payload_any(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_default_availability_list_single(hass: HomeAssistant, caplog) -> None:
|
async def test_default_availability_list_single(
|
||||||
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||||
|
) -> None:
|
||||||
"""Test availability list and availability_topic are mutually exclusive."""
|
"""Test availability list and availability_topic are mutually exclusive."""
|
||||||
await help_test_default_availability_list_single(
|
await help_test_default_availability_list_single(
|
||||||
hass,
|
hass,
|
||||||
|
@ -930,7 +932,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one sensor per unique_id."""
|
"""Test unique id option only creates one sensor per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -634,7 +634,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one siren per unique_id."""
|
"""Test unique id option only creates one siren per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -244,7 +244,9 @@ async def test_commands_without_supported_features(
|
||||||
mqtt_mock.async_publish.assert_not_called()
|
mqtt_mock.async_publish.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
async def test_status(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_status(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> 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])
|
||||||
config[mqttvacuum.CONF_SUPPORTED_FEATURES] = services_to_strings(
|
config[mqttvacuum.CONF_SUPPORTED_FEATURES] = services_to_strings(
|
||||||
|
@ -479,7 +481,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one vacuum per unique_id."""
|
"""Test unique id option only creates one vacuum per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -403,7 +403,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one switch per unique_id."""
|
"""Test unique id option only creates one switch per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""The tests for MQTT tag scanner."""
|
"""The tests for MQTT tag scanner."""
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import ANY, patch
|
from unittest.mock import ANY, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -63,7 +64,7 @@ def tag_mock():
|
||||||
@pytest.mark.no_fail_on_log_exception
|
@pytest.mark.no_fail_on_log_exception
|
||||||
async def test_discover_bad_tag(
|
async def test_discover_bad_tag(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
tag_mock,
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -90,7 +91,7 @@ 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,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
tag_mock,
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -110,7 +111,7 @@ 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,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
tag_mock,
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -129,7 +130,7 @@ 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,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
tag_mock,
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -167,7 +168,7 @@ 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,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
tag_mock,
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -263,7 +264,7 @@ 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,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
tag_mock,
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -312,7 +313,7 @@ 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,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test subscription to topics without change."""
|
"""Test subscription to topics without change."""
|
||||||
|
@ -331,7 +332,7 @@ 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,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
tag_mock,
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -404,7 +405,7 @@ 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: WebSocketGenerator,
|
hass_ws_client: WebSocketGenerator,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
tag_mock,
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -552,7 +553,7 @@ async def test_entity_device_info_update(
|
||||||
async def test_cleanup_tag(
|
async def test_cleanup_tag(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: WebSocketGenerator,
|
hass_ws_client: WebSocketGenerator,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
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."""
|
||||||
|
@ -635,7 +636,7 @@ async def test_cleanup_tag(
|
||||||
|
|
||||||
async def test_cleanup_device(
|
async def test_cleanup_device(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
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."""
|
||||||
|
@ -663,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: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||||
tag_mock,
|
tag_mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -711,7 +712,7 @@ 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,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
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.
|
||||||
|
@ -778,7 +779,7 @@ 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,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
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.
|
||||||
|
@ -889,10 +890,10 @@ async def test_update_with_bad_config_not_breaks_discovery(
|
||||||
|
|
||||||
async def test_unload_entry(
|
async def test_unload_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry,
|
device_registry: dr.DeviceRegistry,
|
||||||
mqtt_mock: MqttMockHAClient,
|
mqtt_mock: MqttMockHAClient,
|
||||||
tag_mock,
|
tag_mock,
|
||||||
tmp_path,
|
tmp_path: Path,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test unloading the MQTT entry."""
|
"""Test unloading the MQTT entry."""
|
||||||
|
|
||||||
|
|
|
@ -439,7 +439,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one text per unique_id."""
|
"""Test unique id option only creates one text per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
|
@ -180,7 +180,9 @@ async def test_if_fires_on_payload_template(hass: HomeAssistant, calls) -> None:
|
||||||
assert len(calls) == 1
|
assert len(calls) == 1
|
||||||
|
|
||||||
|
|
||||||
async def test_non_allowed_templates(hass: HomeAssistant, calls, caplog) -> None:
|
async def test_non_allowed_templates(
|
||||||
|
hass: HomeAssistant, calls, caplog: pytest.LogCaptureFixture
|
||||||
|
) -> None:
|
||||||
"""Test non allowed function in template."""
|
"""Test non allowed function in template."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
|
|
|
@ -528,7 +528,9 @@ async def test_discovery_update_attr(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_unique_id(hass: HomeAssistant, mqtt_mock_entry_with_yaml_config) -> None:
|
async def test_unique_id(
|
||||||
|
hass: HomeAssistant, mqtt_mock_entry_with_yaml_config: MqttMockHAClientGenerator
|
||||||
|
) -> None:
|
||||||
"""Test unique id option only creates one update per unique_id."""
|
"""Test unique id option only creates one update per unique_id."""
|
||||||
config = {
|
config = {
|
||||||
mqtt.DOMAIN: {
|
mqtt.DOMAIN: {
|
||||||
|
|
Loading…
Add table
Reference in a new issue