Cleanup mqtt platform tests part 2 (#120490)

This commit is contained in:
Jan Bouwhuis 2024-06-26 08:53:28 +02:00 committed by GitHub
parent cef1d35e31
commit fab901f9b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 67 additions and 126 deletions

View File

@ -697,9 +697,7 @@ async def test_position_via_template_and_entity_id(
], ],
) )
async def test_optimistic_flag( async def test_optimistic_flag(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, assumed_state: bool
mqtt_mock_entry: MqttMockHAClientGenerator,
assumed_state: bool,
) -> None: ) -> None:
"""Test assumed_state is set correctly.""" """Test assumed_state is set correctly."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -1073,10 +1071,9 @@ async def test_current_cover_position_inverted(
} }
], ],
) )
@pytest.mark.usefixtures("hass")
async def test_optimistic_position( async def test_optimistic_position(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, mqtt_mock_entry: MqttMockHAClientGenerator
caplog: pytest.LogCaptureFixture,
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Test optimistic position is not supported.""" """Test optimistic position is not supported."""
assert await mqtt_mock_entry() assert await mqtt_mock_entry()
@ -1627,7 +1624,6 @@ async def test_tilt_via_invocation_defaults(
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
) -> None: ) -> None:
"""Test tilt defaults on close/open.""" """Test tilt defaults on close/open."""
await hass.async_block_till_done()
mqtt_mock = await mqtt_mock_entry() mqtt_mock = await mqtt_mock_entry()
await hass.services.async_call( await hass.services.async_call(
@ -2547,11 +2543,7 @@ async def test_update_with_json_attrs_not_dict(
) -> 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(
hass, hass, mqtt_mock_entry, caplog, cover.DOMAIN, DEFAULT_CONFIG
mqtt_mock_entry,
caplog,
cover.DOMAIN,
DEFAULT_CONFIG,
) )
@ -2562,11 +2554,7 @@ async def test_update_with_json_attrs_bad_json(
) -> 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(
hass, hass, mqtt_mock_entry, caplog, cover.DOMAIN, DEFAULT_CONFIG
mqtt_mock_entry,
caplog,
cover.DOMAIN,
DEFAULT_CONFIG,
) )
@ -3221,10 +3209,9 @@ async def test_position_via_position_topic_template_return_invalid_json(
} }
], ],
) )
@pytest.mark.usefixtures("hass")
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: pytest.LogCaptureFixture, mqtt_mock_entry: MqttMockHAClientGenerator
caplog: pytest.LogCaptureFixture,
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> 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 await mqtt_mock_entry() assert await mqtt_mock_entry()
@ -3247,8 +3234,8 @@ async def test_set_position_topic_without_get_position_topic_error(
} }
], ],
) )
@pytest.mark.usefixtures("hass")
async def test_value_template_without_state_topic_error( async def test_value_template_without_state_topic_error(
hass: HomeAssistant,
caplog: pytest.LogCaptureFixture, caplog: pytest.LogCaptureFixture,
mqtt_mock_entry: MqttMockHAClientGenerator, mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
@ -3273,8 +3260,8 @@ async def test_value_template_without_state_topic_error(
} }
], ],
) )
@pytest.mark.usefixtures("hass")
async def test_position_template_without_position_topic_error( async def test_position_template_without_position_topic_error(
hass: HomeAssistant,
caplog: pytest.LogCaptureFixture, caplog: pytest.LogCaptureFixture,
mqtt_mock_entry: MqttMockHAClientGenerator, mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
@ -3300,10 +3287,9 @@ async def test_position_template_without_position_topic_error(
} }
], ],
) )
@pytest.mark.usefixtures("hass")
async def test_set_position_template_without_set_position_topic( async def test_set_position_template_without_set_position_topic(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, mqtt_mock_entry: MqttMockHAClientGenerator
caplog: pytest.LogCaptureFixture,
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> 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 await mqtt_mock_entry() assert await mqtt_mock_entry()
@ -3327,10 +3313,9 @@ async def test_set_position_template_without_set_position_topic(
} }
], ],
) )
@pytest.mark.usefixtures("hass")
async def test_tilt_command_template_without_tilt_command_topic( async def test_tilt_command_template_without_tilt_command_topic(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, mqtt_mock_entry: MqttMockHAClientGenerator
caplog: pytest.LogCaptureFixture,
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> 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 await mqtt_mock_entry() assert await mqtt_mock_entry()
@ -3354,10 +3339,9 @@ async def test_tilt_command_template_without_tilt_command_topic(
} }
], ],
) )
@pytest.mark.usefixtures("hass")
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: pytest.LogCaptureFixture, mqtt_mock_entry: MqttMockHAClientGenerator
caplog: pytest.LogCaptureFixture,
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> 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 await mqtt_mock_entry() assert await mqtt_mock_entry()
@ -3423,8 +3407,7 @@ async def test_publishing_with_custom_encoding(
async def test_reloadable( async def test_reloadable(
hass: HomeAssistant, hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
mqtt_client_mock: MqttMockPahoClient,
) -> None: ) -> None:
"""Test reloading the MQTT platform.""" """Test reloading the MQTT platform."""
domain = cover.DOMAIN domain = cover.DOMAIN

View File

@ -334,9 +334,7 @@ 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, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: 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() await mqtt_mock_entry()
@ -361,9 +359,7 @@ 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, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: 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() await mqtt_mock_entry()
@ -391,9 +387,7 @@ 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, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: 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() await mqtt_mock_entry()
@ -415,9 +409,7 @@ 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, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
) -> None: ) -> None:
"""Test the setting of the latitude and longitude via MQTT without state topic.""" """Test the setting of the latitude and longitude via MQTT without state topic."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -472,9 +464,7 @@ 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, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: 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() await mqtt_mock_entry()
@ -548,9 +538,7 @@ 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, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: 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() await mqtt_mock_entry()
@ -625,8 +613,7 @@ async def test_setup_with_modern_schema(
async def test_reloadable( async def test_reloadable(
hass: HomeAssistant, hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
mqtt_client_mock: MqttMockPahoClient,
) -> None: ) -> None:
"""Test reloading the MQTT platform.""" """Test reloading the MQTT platform."""
domain = device_tracker.DOMAIN domain = device_tracker.DOMAIN

View File

@ -1,6 +1,7 @@
"""The tests for MQTT device triggers.""" """The tests for MQTT device triggers."""
import json import json
from typing import Any
import pytest import pytest
from pytest_unordered import unordered from pytest_unordered import unordered
@ -194,7 +195,6 @@ async def test_update_remove_triggers(
hass: HomeAssistant, hass: HomeAssistant,
device_registry: dr.DeviceRegistry, device_registry: dr.DeviceRegistry,
mqtt_mock_entry: MqttMockHAClientGenerator, mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
) -> None: ) -> None:
"""Test triggers can be updated and removed.""" """Test triggers can be updated and removed."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -1016,10 +1016,10 @@ async def test_attach_remove(
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_registry.async_get_device(identifiers={("mqtt", "0AFFD2")}) device_entry = device_registry.async_get_device(identifiers={("mqtt", "0AFFD2")})
calls = [] callback_calls: list[dict[str, Any]] = []
def callback(trigger): def trigger_callback(trigger):
calls.append(trigger["trigger"]["payload"]) callback_calls.append(trigger["trigger"]["payload"])
remove = await async_initialize_triggers( remove = await async_initialize_triggers(
hass, hass,
@ -1033,7 +1033,7 @@ async def test_attach_remove(
"subtype": "button_1", "subtype": "button_1",
}, },
], ],
callback, trigger_callback,
DOMAIN, DOMAIN,
"mock-name", "mock-name",
_LOGGER.log, _LOGGER.log,
@ -1042,8 +1042,8 @@ async def test_attach_remove(
# Fake short press. # Fake short press.
async_fire_mqtt_message(hass, "foobar/triggers/button1", "short_press") async_fire_mqtt_message(hass, "foobar/triggers/button1", "short_press")
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(calls) == 1 assert len(callback_calls) == 1
assert calls[0] == "short_press" assert callback_calls[0] == "short_press"
# Remove the trigger # Remove the trigger
remove() remove()
@ -1052,7 +1052,7 @@ async def test_attach_remove(
# Verify the triggers are no longer active # Verify the triggers are no longer active
async_fire_mqtt_message(hass, "foobar/triggers/button1", "short_press") async_fire_mqtt_message(hass, "foobar/triggers/button1", "short_press")
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(calls) == 1 assert len(callback_calls) == 1
async def test_attach_remove_late( async def test_attach_remove_late(
@ -1079,10 +1079,10 @@ async def test_attach_remove_late(
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_registry.async_get_device(identifiers={("mqtt", "0AFFD2")}) device_entry = device_registry.async_get_device(identifiers={("mqtt", "0AFFD2")})
calls = [] callback_calls: list[dict[str, Any]] = []
def callback(trigger): def trigger_callback(trigger):
calls.append(trigger["trigger"]["payload"]) callback_calls.append(trigger["trigger"]["payload"])
remove = await async_initialize_triggers( remove = await async_initialize_triggers(
hass, hass,
@ -1096,7 +1096,7 @@ async def test_attach_remove_late(
"subtype": "button_1", "subtype": "button_1",
}, },
], ],
callback, trigger_callback,
DOMAIN, DOMAIN,
"mock-name", "mock-name",
_LOGGER.log, _LOGGER.log,
@ -1108,8 +1108,8 @@ async def test_attach_remove_late(
# Fake short press. # Fake short press.
async_fire_mqtt_message(hass, "foobar/triggers/button1", "short_press") async_fire_mqtt_message(hass, "foobar/triggers/button1", "short_press")
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(calls) == 1 assert len(callback_calls) == 1
assert calls[0] == "short_press" assert callback_calls[0] == "short_press"
# Remove the trigger # Remove the trigger
remove() remove()
@ -1118,7 +1118,7 @@ async def test_attach_remove_late(
# Verify the triggers are no longer active # Verify the triggers are no longer active
async_fire_mqtt_message(hass, "foobar/triggers/button1", "short_press") async_fire_mqtt_message(hass, "foobar/triggers/button1", "short_press")
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(calls) == 1 assert len(callback_calls) == 1
async def test_attach_remove_late2( async def test_attach_remove_late2(
@ -1145,10 +1145,10 @@ async def test_attach_remove_late2(
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_registry.async_get_device(identifiers={("mqtt", "0AFFD2")}) device_entry = device_registry.async_get_device(identifiers={("mqtt", "0AFFD2")})
calls = [] callback_calls: list[dict[str, Any]] = []
def callback(trigger): def trigger_callback(trigger):
calls.append(trigger["trigger"]["payload"]) callback_calls.append(trigger["trigger"]["payload"])
remove = await async_initialize_triggers( remove = await async_initialize_triggers(
hass, hass,
@ -1162,7 +1162,7 @@ async def test_attach_remove_late2(
"subtype": "button_1", "subtype": "button_1",
}, },
], ],
callback, trigger_callback,
DOMAIN, DOMAIN,
"mock-name", "mock-name",
_LOGGER.log, _LOGGER.log,
@ -1178,7 +1178,7 @@ async def test_attach_remove_late2(
# Verify the triggers are no longer active # Verify the triggers are no longer active
async_fire_mqtt_message(hass, "foobar/triggers/button1", "short_press") async_fire_mqtt_message(hass, "foobar/triggers/button1", "short_press")
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(calls) == 0 assert len(callback_calls) == 0
# Try to remove the trigger twice # Try to remove the trigger twice
with pytest.raises(HomeAssistantError): with pytest.raises(HomeAssistantError):

View File

@ -26,7 +26,6 @@ default_config = {
async def test_entry_diagnostics( async def test_entry_diagnostics(
hass: HomeAssistant, hass: HomeAssistant,
device_registry: dr.DeviceRegistry, device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
hass_client: ClientSessionGenerator, hass_client: ClientSessionGenerator,
mqtt_mock_entry: MqttMockHAClientGenerator, mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:

View File

@ -64,8 +64,7 @@ from tests.typing import (
[{mqtt.CONF_BROKER: "mock-broker", mqtt.CONF_DISCOVERY: False}], [{mqtt.CONF_BROKER: "mock-broker", mqtt.CONF_DISCOVERY: False}],
) )
async def test_subscribing_config_topic( async def test_subscribing_config_topic(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Test setting up discovery.""" """Test setting up discovery."""
mqtt_mock = await mqtt_mock_entry() mqtt_mock = await mqtt_mock_entry()
@ -205,8 +204,7 @@ async def test_only_valid_components(
async def test_correct_config_discovery( async def test_correct_config_discovery(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Test sending in correct JSON.""" """Test sending in correct JSON."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -285,9 +283,7 @@ async def test_discovery_with_invalid_integration_info(
"""Test sending in correct JSON.""" """Test sending in correct JSON."""
await mqtt_mock_entry() await mqtt_mock_entry()
async_fire_mqtt_message( async_fire_mqtt_message(
hass, hass, "homeassistant/binary_sensor/bla/config", config_message
"homeassistant/binary_sensor/bla/config",
config_message,
) )
await hass.async_block_till_done() await hass.async_block_till_done()
@ -298,8 +294,7 @@ async def test_discovery_with_invalid_integration_info(
async def test_discover_fan( async def test_discover_fan(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Test discovering an MQTT fan.""" """Test discovering an MQTT fan."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -318,9 +313,7 @@ async def test_discover_fan(
async def test_discover_climate( async def test_discover_climate(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
) -> None: ) -> None:
"""Test discovering an MQTT climate component.""" """Test discovering an MQTT climate component."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -341,8 +334,7 @@ async def test_discover_climate(
async def test_discover_alarm_control_panel( async def test_discover_alarm_control_panel(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Test discovering an MQTT alarm control panel component.""" """Test discovering an MQTT alarm control panel component."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -531,8 +523,7 @@ async def test_discovery_with_object_id(
async def test_discovery_incl_nodeid( async def test_discovery_incl_nodeid(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Test sending in correct JSON with optional node_id included.""" """Test sending in correct JSON with optional node_id included."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -581,8 +572,7 @@ async def test_non_duplicate_discovery(
async def test_removal( async def test_removal(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Test removal of component through empty discovery message.""" """Test removal of component through empty discovery message."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -602,8 +592,7 @@ async def test_removal(
async def test_rediscover( async def test_rediscover(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Test rediscover of removed component.""" """Test rediscover of removed component."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -632,8 +621,7 @@ async def test_rediscover(
async def test_rapid_rediscover( async def test_rapid_rediscover(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Test immediate rediscover of removed component.""" """Test immediate rediscover of removed component."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -684,8 +672,7 @@ async def test_rapid_rediscover(
async def test_rapid_rediscover_unique( async def test_rapid_rediscover_unique(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Test immediate rediscover of removed component.""" """Test immediate rediscover of removed component."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -746,8 +733,7 @@ async def test_rapid_rediscover_unique(
async def test_rapid_reconfigure( async def test_rapid_reconfigure(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Test immediate reconfigure of added component.""" """Test immediate reconfigure of added component."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -1110,8 +1096,7 @@ async def test_cleanup_device_multiple_config_entries_mqtt(
async def test_discovery_expansion( async def test_discovery_expansion(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Test expansion of abbreviated discovery payload.""" """Test expansion of abbreviated discovery payload."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -1172,8 +1157,7 @@ async def test_discovery_expansion(
async def test_discovery_expansion_2( async def test_discovery_expansion_2(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Test expansion of abbreviated discovery payload.""" """Test expansion of abbreviated discovery payload."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -1249,8 +1233,7 @@ async def test_discovery_expansion_3(
async def test_discovery_expansion_without_encoding_and_value_template_1( async def test_discovery_expansion_without_encoding_and_value_template_1(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Test expansion of raw availability payload with a template as list.""" """Test expansion of raw availability payload with a template as list."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -1300,8 +1283,7 @@ async def test_discovery_expansion_without_encoding_and_value_template_1(
async def test_discovery_expansion_without_encoding_and_value_template_2( async def test_discovery_expansion_without_encoding_and_value_template_2(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Test expansion of raw availability payload with a template directly.""" """Test expansion of raw availability payload with a template directly."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -1379,7 +1361,6 @@ EXCLUDED_MODULES = {
async def test_missing_discover_abbreviations( async def test_missing_discover_abbreviations(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator, mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Check MQTT platforms for missing abbreviations.""" """Check MQTT platforms for missing abbreviations."""
@ -1403,8 +1384,7 @@ async def test_missing_discover_abbreviations(
async def test_no_implicit_state_topic_switch( async def test_no_implicit_state_topic_switch(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Test no implicit state topic for switch.""" """Test no implicit state topic for switch."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -1462,8 +1442,7 @@ async def test_complex_discovery_topic_prefix(
@patch("homeassistant.components.mqtt.client.SUBSCRIBE_COOLDOWN", 0.0) @patch("homeassistant.components.mqtt.client.SUBSCRIBE_COOLDOWN", 0.0)
@patch("homeassistant.components.mqtt.client.UNSUBSCRIBE_COOLDOWN", 0.0) @patch("homeassistant.components.mqtt.client.UNSUBSCRIBE_COOLDOWN", 0.0)
async def test_mqtt_integration_discovery_subscribe_unsubscribe( async def test_mqtt_integration_discovery_subscribe_unsubscribe(
hass: HomeAssistant, hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
mqtt_client_mock: MqttMockPahoClient,
) -> None: ) -> None:
"""Check MQTT integration discovery subscribe and unsubscribe.""" """Check MQTT integration discovery subscribe and unsubscribe."""
@ -1521,8 +1500,7 @@ async def test_mqtt_integration_discovery_subscribe_unsubscribe(
@patch("homeassistant.components.mqtt.client.SUBSCRIBE_COOLDOWN", 0.0) @patch("homeassistant.components.mqtt.client.SUBSCRIBE_COOLDOWN", 0.0)
@patch("homeassistant.components.mqtt.client.UNSUBSCRIBE_COOLDOWN", 0.0) @patch("homeassistant.components.mqtt.client.UNSUBSCRIBE_COOLDOWN", 0.0)
async def test_mqtt_discovery_unsubscribe_once( async def test_mqtt_discovery_unsubscribe_once(
hass: HomeAssistant, hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
mqtt_client_mock: MqttMockPahoClient,
) -> None: ) -> None:
"""Check MQTT integration discovery unsubscribe once.""" """Check MQTT integration discovery unsubscribe once."""
@ -1657,7 +1635,6 @@ async def test_clean_up_registry_monitoring(
hass: HomeAssistant, hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator, mqtt_mock_entry: MqttMockHAClientGenerator,
device_registry: dr.DeviceRegistry, device_registry: dr.DeviceRegistry,
tmp_path: Path,
) -> None: ) -> None:
"""Test registry monitoring hook is removed after a reload.""" """Test registry monitoring hook is removed after a reload."""
await mqtt_mock_entry() await mqtt_mock_entry()

View File

@ -325,10 +325,9 @@ async def test_discovery_update_availability(
} }
], ],
) )
@pytest.mark.usefixtures("hass")
async def test_invalid_device_class( async def test_invalid_device_class(
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, caplog: pytest.LogCaptureFixture
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
) -> None: ) -> None:
"""Test device_class option with invalid value.""" """Test device_class option with invalid value."""
assert await mqtt_mock_entry() assert await mqtt_mock_entry()
@ -444,9 +443,7 @@ async def test_discovery_removal_event(
async def test_discovery_update_event_template( async def test_discovery_update_event_template(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
) -> None: ) -> None:
"""Test update of discovered mqtt event template.""" """Test update of discovered mqtt event template."""
await mqtt_mock_entry() await mqtt_mock_entry()
@ -665,8 +662,7 @@ async def test_value_template_with_entity_id(
async def test_reloadable( async def test_reloadable(
hass: HomeAssistant, hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient
mqtt_client_mock: MqttMockPahoClient,
) -> None: ) -> None:
"""Test reloading the MQTT platform.""" """Test reloading the MQTT platform."""
domain = event.DOMAIN domain = event.DOMAIN
@ -689,8 +685,7 @@ async def test_setup_manual_entity_from_yaml(
async def test_unload_entry( async def test_unload_entry(
hass: HomeAssistant, hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None: ) -> None:
"""Test unloading the config entry.""" """Test unloading the config entry."""
domain = event.DOMAIN domain = event.DOMAIN