Cleanup mqtt platform tests part 6 (last) (#120736)

This commit is contained in:
Jan Bouwhuis 2024-06-28 16:22:25 +02:00 committed by GitHub
parent d03a6f84a3
commit a8f4684929
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 109 additions and 442 deletions

View file

@ -853,10 +853,7 @@ async def test_availability_without_topic(
) -> None:
"""Test availability without defined availability topic."""
await help_test_availability_without_topic(
hass,
mqtt_mock_entry,
alarm_control_panel.DOMAIN,
DEFAULT_CONFIG_CODE,
hass, mqtt_mock_entry, alarm_control_panel.DOMAIN, DEFAULT_CONFIG_CODE
)
@ -865,10 +862,7 @@ async def test_default_availability_payload(
) -> None:
"""Test availability by default payload with defined topic."""
await help_test_default_availability_payload(
hass,
mqtt_mock_entry,
alarm_control_panel.DOMAIN,
DEFAULT_CONFIG_CODE,
hass, mqtt_mock_entry, alarm_control_panel.DOMAIN, DEFAULT_CONFIG_CODE
)
@ -877,10 +871,7 @@ async def test_custom_availability_payload(
) -> None:
"""Test availability by custom payload with defined topic."""
await help_test_custom_availability_payload(
hass,
mqtt_mock_entry,
alarm_control_panel.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, alarm_control_panel.DOMAIN, DEFAULT_CONFIG
)
@ -889,10 +880,7 @@ async def test_setting_attribute_via_mqtt_json_message(
) -> None:
"""Test the setting of attribute via MQTT with JSON payload."""
await help_test_setting_attribute_via_mqtt_json_message(
hass,
mqtt_mock_entry,
alarm_control_panel.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, alarm_control_panel.DOMAIN, DEFAULT_CONFIG
)
@ -914,10 +902,7 @@ async def test_setting_attribute_with_template(
) -> None:
"""Test the setting of attribute via MQTT with JSON payload."""
await help_test_setting_attribute_with_template(
hass,
mqtt_mock_entry,
alarm_control_panel.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, alarm_control_panel.DOMAIN, DEFAULT_CONFIG
)
@ -928,11 +913,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
alarm_control_panel.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, alarm_control_panel.DOMAIN, DEFAULT_CONFIG
)
@ -943,11 +924,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
alarm_control_panel.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, alarm_control_panel.DOMAIN, DEFAULT_CONFIG
)

View file

@ -758,10 +758,7 @@ async def test_setting_attribute_with_template(
) -> None:
"""Test the setting of attribute via MQTT with JSON payload."""
await help_test_setting_attribute_with_template(
hass,
mqtt_mock_entry,
binary_sensor.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, binary_sensor.DOMAIN, DEFAULT_CONFIG
)
@ -772,11 +769,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
binary_sensor.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, binary_sensor.DOMAIN, DEFAULT_CONFIG
)
@ -787,11 +780,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
binary_sensor.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, binary_sensor.DOMAIN, DEFAULT_CONFIG
)

View file

@ -216,11 +216,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
button.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, button.DOMAIN, DEFAULT_CONFIG
)
@ -231,11 +227,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
button.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, button.DOMAIN, DEFAULT_CONFIG
)

View file

@ -1867,11 +1867,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
climate.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, climate.DOMAIN, DEFAULT_CONFIG
)
@ -1882,11 +1878,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
climate.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, climate.DOMAIN, DEFAULT_CONFIG
)

View file

@ -584,11 +584,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
) -> None:
"""Test the setting of attribute via MQTT with JSON payload."""
await help_test_setting_blocked_attribute_via_mqtt_json_message(
hass,
mqtt_mock_entry,
device_tracker.DOMAIN,
DEFAULT_CONFIG,
None,
hass, mqtt_mock_entry, device_tracker.DOMAIN, DEFAULT_CONFIG, None
)

View file

@ -372,11 +372,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
event.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, event.DOMAIN, DEFAULT_CONFIG
)
@ -387,11 +383,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
event.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, event.DOMAIN, DEFAULT_CONFIG
)

View file

@ -1932,11 +1932,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
) -> None:
"""Test the setting of attribute via MQTT with JSON payload."""
await help_test_setting_blocked_attribute_via_mqtt_json_message(
hass,
mqtt_mock_entry,
fan.DOMAIN,
DEFAULT_CONFIG,
MQTT_FAN_ATTRIBUTES_BLOCKED,
hass, mqtt_mock_entry, fan.DOMAIN, DEFAULT_CONFIG, MQTT_FAN_ATTRIBUTES_BLOCKED
)
@ -1956,11 +1952,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
fan.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, fan.DOMAIN, DEFAULT_CONFIG
)
@ -1971,11 +1963,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
fan.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, fan.DOMAIN, DEFAULT_CONFIG
)

View file

@ -1246,11 +1246,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
humidifier.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, humidifier.DOMAIN, DEFAULT_CONFIG
)
@ -1261,11 +1257,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
humidifier.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, humidifier.DOMAIN, DEFAULT_CONFIG
)

View file

@ -573,11 +573,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
image.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, image.DOMAIN, DEFAULT_CONFIG
)
@ -588,11 +584,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
image.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, image.DOMAIN, DEFAULT_CONFIG
)

View file

@ -442,11 +442,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
lawn_mower.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, lawn_mower.DOMAIN, DEFAULT_CONFIG
)
@ -457,11 +453,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
lawn_mower.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, lawn_mower.DOMAIN, DEFAULT_CONFIG
)

View file

@ -2492,11 +2492,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
light.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, light.DOMAIN, DEFAULT_CONFIG
)
@ -2507,11 +2503,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
light.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, light.DOMAIN, DEFAULT_CONFIG
)

View file

@ -2374,11 +2374,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
light.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, light.DOMAIN, DEFAULT_CONFIG
)
@ -2389,11 +2385,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
light.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, light.DOMAIN, DEFAULT_CONFIG
)

View file

@ -978,11 +978,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
light.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, light.DOMAIN, DEFAULT_CONFIG
)
@ -993,11 +989,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
light.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, light.DOMAIN, DEFAULT_CONFIG
)

View file

@ -757,11 +757,7 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
) -> None:
"""Test the setting of attribute via MQTT with JSON payload."""
await help_test_setting_blocked_attribute_via_mqtt_json_message(
hass,
mqtt_mock_entry,
lock.DOMAIN,
DEFAULT_CONFIG,
MQTT_LOCK_ATTRIBUTES_BLOCKED,
hass, mqtt_mock_entry, lock.DOMAIN, DEFAULT_CONFIG, MQTT_LOCK_ATTRIBUTES_BLOCKED
)
@ -781,11 +777,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
lock.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, lock.DOMAIN, DEFAULT_CONFIG
)
@ -796,11 +788,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
lock.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, lock.DOMAIN, DEFAULT_CONFIG
)

View file

@ -199,11 +199,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
notify.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, notify.DOMAIN, DEFAULT_CONFIG
)
@ -214,11 +210,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
notify.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, notify.DOMAIN, DEFAULT_CONFIG
)

View file

@ -557,11 +557,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
number.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, number.DOMAIN, DEFAULT_CONFIG
)
@ -572,11 +568,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
number.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, number.DOMAIN, DEFAULT_CONFIG
)

View file

@ -263,11 +263,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
scene.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, scene.DOMAIN, DEFAULT_CONFIG
)
@ -278,11 +274,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
scene.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, scene.DOMAIN, DEFAULT_CONFIG
)

View file

@ -407,11 +407,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
select.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, select.DOMAIN, DEFAULT_CONFIG
)

View file

@ -617,9 +617,7 @@ async def test_setting_sensor_last_reset_via_mqtt_json_message(
],
)
async def test_setting_sensor_last_reset_via_mqtt_json_message_2(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test the setting of the value via MQTT with JSON payload."""
await hass.async_block_till_done()
@ -810,9 +808,7 @@ async def test_discovery_update_availability(
],
)
async def test_invalid_device_class(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
mqtt_mock_entry: MqttMockHAClientGenerator, caplog: pytest.LogCaptureFixture
) -> None:
"""Test device_class option with invalid value."""
assert await mqtt_mock_entry()
@ -871,9 +867,7 @@ async def test_valid_device_class_and_uom(
],
)
async def test_invalid_state_class(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
mqtt_mock_entry: MqttMockHAClientGenerator, caplog: pytest.LogCaptureFixture
) -> None:
"""Test state_class option with invalid value."""
assert await mqtt_mock_entry()
@ -954,11 +948,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
sensor.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, sensor.DOMAIN, DEFAULT_CONFIG
)
@ -969,11 +959,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
sensor.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, sensor.DOMAIN, DEFAULT_CONFIG
)
@ -1298,8 +1284,7 @@ async def test_value_template_with_entity_id(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = sensor.DOMAIN
@ -1454,8 +1439,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = sensor.DOMAIN

View file

@ -60,9 +60,7 @@ DEFAULT_CONFIG = {
async def async_turn_on(
hass: HomeAssistant,
entity_id: str,
parameters: dict[str, Any],
hass: HomeAssistant, entity_id: str, parameters: dict[str, Any]
) -> None:
"""Turn all or specified siren on."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else {}
@ -180,9 +178,7 @@ async def test_sending_mqtt_commands_and_optimistic(
],
)
async def test_controlling_state_via_topic_and_json_message(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test the controlling state via topic and JSON message."""
await mqtt_mock_entry()
@ -618,11 +614,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
siren.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, siren.DOMAIN, DEFAULT_CONFIG
)
@ -633,11 +625,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
siren.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, siren.DOMAIN, DEFAULT_CONFIG
)
@ -787,8 +775,7 @@ async def test_discovery_update_siren_template(
],
)
async def test_command_templates(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test siren with command templates optimistic."""
mqtt_mock = await mqtt_mock_entry()
@ -1005,8 +992,7 @@ async def test_publishing_with_custom_encoding(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = siren.DOMAIN
@ -1016,9 +1002,7 @@ async def test_reloadable(
@pytest.mark.parametrize(
("topic", "value", "attribute", "attribute_value"),
[
("state_topic", "ON", None, "on"),
],
[("state_topic", "ON", None, "on")],
)
async def test_encoding_subscribable_topics(
hass: HomeAssistant,
@ -1056,8 +1040,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = siren.DOMAIN

View file

@ -2,8 +2,6 @@
from unittest.mock import ANY
import pytest
from homeassistant.components.mqtt.subscription import (
async_prepare_subscribe_topics,
async_subscribe_topics,
@ -16,9 +14,7 @@ from tests.typing import MqttMockHAClientGenerator
async def test_subscribe_topics(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test subscription to topics."""
await mqtt_mock_entry()
@ -69,9 +65,7 @@ async def test_subscribe_topics(
async def test_modify_topics(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test modification of topics."""
await mqtt_mock_entry()
@ -136,9 +130,7 @@ async def test_modify_topics(
async def test_qos_encoding_default(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test default qos and encoding."""
mqtt_mock = await mqtt_mock_entry()
@ -158,9 +150,7 @@ async def test_qos_encoding_default(
async def test_qos_encoding_custom(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test custom qos and encoding."""
mqtt_mock = await mqtt_mock_entry()
@ -187,9 +177,7 @@ async def test_qos_encoding_custom(
async def test_no_change(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test subscription to topics without change."""
mqtt_mock = await mqtt_mock_entry()

View file

@ -379,11 +379,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
switch.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, switch.DOMAIN, DEFAULT_CONFIG
)
@ -394,11 +390,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
switch.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, switch.DOMAIN, DEFAULT_CONFIG
)
@ -524,8 +516,7 @@ async def test_discovery_update_switch_template(
async def test_discovery_update_unchanged_switch(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test update of discovered switch."""
data1 = (
@ -675,8 +666,7 @@ async def test_publishing_with_custom_encoding(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = switch.DOMAIN
@ -726,8 +716,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = switch.DOMAIN

View file

@ -20,7 +20,7 @@ from tests.common import (
async_fire_mqtt_message,
async_get_device_automations,
)
from tests.typing import MqttMockHAClient, MqttMockHAClientGenerator, WebSocketGenerator
from tests.typing import MqttMockHAClientGenerator, WebSocketGenerator
DEFAULT_CONFIG_DEVICE = {
"device": {"identifiers": ["0AFFD2"]},
@ -102,9 +102,7 @@ async def test_if_fires_on_mqtt_message_with_device(
async def test_if_fires_on_mqtt_message_without_device(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
tag_mock: AsyncMock,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, tag_mock: AsyncMock
) -> None:
"""Test tag scanning, without device."""
await mqtt_mock_entry()
@ -140,9 +138,7 @@ async def test_if_fires_on_mqtt_message_with_template(
async def test_strip_tag_id(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
tag_mock: AsyncMock,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, tag_mock: AsyncMock
) -> None:
"""Test strip whitespace from tag_id."""
await mqtt_mock_entry()
@ -208,9 +204,7 @@ async def test_if_fires_on_mqtt_message_after_update_with_device(
async def test_if_fires_on_mqtt_message_after_update_without_device(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
tag_mock: AsyncMock,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, tag_mock: AsyncMock
) -> None:
"""Test tag scanning after update."""
await mqtt_mock_entry()
@ -359,9 +353,7 @@ 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(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
tag_mock: AsyncMock,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, tag_mock: AsyncMock
) -> None:
"""Test tag scanning not firing after removal."""
await mqtt_mock_entry()
@ -904,11 +896,9 @@ async def test_update_with_bad_config_not_breaks_discovery(
tag_mock.assert_called_once_with(ANY, "12345", ANY)
@pytest.mark.usefixtures("mqtt_mock")
async def test_unload_entry(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
mqtt_mock: MqttMockHAClient,
tag_mock: AsyncMock,
hass: HomeAssistant, device_registry: dr.DeviceRegistry, tag_mock: AsyncMock
) -> None:
"""Test unloading the MQTT entry."""
@ -934,12 +924,9 @@ async def test_unload_entry(
tag_mock.assert_not_called()
@pytest.mark.usefixtures("mqtt_mock", "tag_mock")
async def test_value_template_fails(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
mqtt_mock: MqttMockHAClient,
tag_mock: AsyncMock,
caplog: pytest.LogCaptureFixture,
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
) -> None:
"""Test the rendering of MQTT value template fails."""
config = copy.deepcopy(DEFAULT_CONFIG_DEVICE)

View file

@ -251,9 +251,7 @@ async def test_controlling_validation_state_via_topic(
],
)
async def test_attribute_validation_max_greater_then_min(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
mqtt_mock_entry: MqttMockHAClientGenerator, caplog: pytest.LogCaptureFixture
) -> None:
"""Test the validation of min and max configuration attributes."""
assert await mqtt_mock_entry()
@ -276,9 +274,7 @@ async def test_attribute_validation_max_greater_then_min(
],
)
async def test_attribute_validation_max_not_greater_then_max_state_length(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
mqtt_mock_entry: MqttMockHAClientGenerator, caplog: pytest.LogCaptureFixture
) -> None:
"""Test the max value of of max configuration attribute."""
assert await mqtt_mock_entry()
@ -436,13 +432,7 @@ async def test_default_availability_payload(
}
}
await help_test_default_availability_payload(
hass,
mqtt_mock_entry,
text.DOMAIN,
config,
True,
"state-topic",
"some state",
hass, mqtt_mock_entry, text.DOMAIN, config, True, "state-topic", "some state"
)
@ -461,13 +451,7 @@ async def test_custom_availability_payload(
}
await help_test_custom_availability_payload(
hass,
mqtt_mock_entry,
text.DOMAIN,
config,
True,
"state-topic",
"1",
hass, mqtt_mock_entry, text.DOMAIN, config, True, "state-topic", "1"
)
@ -505,11 +489,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
text.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, text.DOMAIN, DEFAULT_CONFIG
)
@ -520,11 +500,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
text.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, text.DOMAIN, DEFAULT_CONFIG
)
@ -754,8 +730,7 @@ async def test_publishing_with_custom_encoding(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = text.DOMAIN
@ -805,8 +780,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = text.DOMAIN

View file

@ -504,11 +504,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
update.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, update.DOMAIN, DEFAULT_CONFIG
)
@ -519,11 +515,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
update.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, update.DOMAIN, DEFAULT_CONFIG
)
@ -679,8 +671,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = update.DOMAIN
@ -691,8 +682,7 @@ async def test_unload_entry(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = update.DOMAIN

View file

@ -507,11 +507,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
vacuum.DOMAIN,
DEFAULT_CONFIG_2,
hass, mqtt_mock_entry, caplog, vacuum.DOMAIN, DEFAULT_CONFIG_2
)
@ -522,11 +518,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
vacuum.DOMAIN,
DEFAULT_CONFIG_2,
hass, mqtt_mock_entry, caplog, vacuum.DOMAIN, DEFAULT_CONFIG_2
)
@ -682,20 +674,8 @@ async def test_entity_debug_info_message(
@pytest.mark.parametrize(
("service", "topic", "parameters", "payload", "template"),
[
(
vacuum.SERVICE_START,
"command_topic",
None,
"start",
None,
),
(
vacuum.SERVICE_CLEAN_SPOT,
"command_topic",
None,
"clean_spot",
None,
),
(vacuum.SERVICE_START, "command_topic", None, "start", None),
(vacuum.SERVICE_CLEAN_SPOT, "command_topic", None, "clean_spot", None),
(
vacuum.SERVICE_SET_FAN_SPEED,
"set_fan_speed_topic",
@ -710,13 +690,7 @@ async def test_entity_debug_info_message(
"custom command",
None,
),
(
vacuum.SERVICE_STOP,
"command_topic",
None,
"stop",
None,
),
(vacuum.SERVICE_STOP, "command_topic", None, "stop", None),
],
)
async def test_publishing_with_custom_encoding(
@ -760,8 +734,7 @@ async def test_publishing_with_custom_encoding(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = vacuum.DOMAIN

View file

@ -306,8 +306,7 @@ async def test_state_via_state_topic_through_position(
],
)
async def test_opening_closing_state_is_reset(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test the controlling state via topic through position.
@ -734,11 +733,7 @@ async def test_controlling_valve_by_position(
)
@pytest.mark.parametrize(
("position", "asserted_message"),
[
(0, "0"),
(30, "30"),
(100, "100"),
],
[(0, "0"), (30, "30"), (100, "100")],
)
async def test_controlling_valve_by_set_valve_position(
hass: HomeAssistant,
@ -842,12 +837,7 @@ async def test_controlling_valve_optimistic_by_set_valve_position(
)
@pytest.mark.parametrize(
("position", "asserted_message"),
[
(0, "-128"),
(30, "-52"),
(80, "76"),
(100, "127"),
],
[(0, "-128"), (30, "-52"), (80, "76"), (100, "127")],
)
async def test_controlling_valve_with_alt_range_by_set_valve_position(
hass: HomeAssistant,
@ -1127,9 +1117,7 @@ async def test_valid_device_class(
],
)
async def test_invalid_device_class(
hass: HomeAssistant,
caplog: pytest.LogCaptureFixture,
mqtt_mock_entry: MqttMockHAClientGenerator,
mqtt_mock_entry: MqttMockHAClientGenerator, caplog: pytest.LogCaptureFixture
) -> None:
"""Test the setting of an invalid device class."""
assert await mqtt_mock_entry()
@ -1174,11 +1162,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
valve.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, valve.DOMAIN, DEFAULT_CONFIG
)
@ -1189,17 +1173,12 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
valve.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, valve.DOMAIN, DEFAULT_CONFIG
)
async def test_discovery_update_attr(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test update of discovered MQTTAttributes."""
await help_test_discovery_update_attr(
@ -1386,8 +1365,7 @@ async def test_publishing_with_custom_encoding(
async def test_reloadable(
hass: HomeAssistant,
mqtt_client_mock: MqttMockPahoClient,
hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
) -> None:
"""Test reloading the MQTT platform."""
domain = valve.DOMAIN
@ -1439,8 +1417,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = valve.DOMAIN

View file

@ -154,9 +154,7 @@ async def test_get_operation_modes(
@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG])
async def test_set_operation_mode_bad_attr_and_state(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test setting operation mode without required attribute."""
await mqtt_mock_entry()
@ -615,8 +613,7 @@ async def test_get_with_templates(
],
)
async def test_set_and_templates(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test setting various attributes with templates."""
mqtt_mock = await mqtt_mock_entry()
@ -834,11 +831,7 @@ async def test_update_with_json_attrs_not_dict(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass,
mqtt_mock_entry,
caplog,
water_heater.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, water_heater.DOMAIN, DEFAULT_CONFIG
)
@ -849,11 +842,7 @@ async def test_update_with_json_attrs_bad_json(
) -> None:
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_json(
hass,
mqtt_mock_entry,
caplog,
water_heater.DOMAIN,
DEFAULT_CONFIG,
hass, mqtt_mock_entry, caplog, water_heater.DOMAIN, DEFAULT_CONFIG
)
@ -1020,11 +1009,7 @@ async def test_entity_id_update_subscriptions(
}
}
await help_test_entity_id_update_subscriptions(
hass,
mqtt_mock_entry,
water_heater.DOMAIN,
config,
["test-topic", "avty-topic"],
hass, mqtt_mock_entry, water_heater.DOMAIN, config, ["test-topic", "avty-topic"]
)
@ -1200,8 +1185,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None:
"""Test unloading the config entry."""
domain = water_heater.DOMAIN