From caaa03536b51101656404e11f944579965793900 Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Sat, 9 Mar 2024 23:48:54 +0100 Subject: [PATCH] Cleanup mqtt PLATFORMS constant and CI-test platform filters (#112847) --- homeassistant/components/mqtt/__init__.py | 1 - homeassistant/components/mqtt/const.py | 28 --------------- .../mqtt/test_alarm_control_panel.py | 10 ------ tests/components/mqtt/test_binary_sensor.py | 8 ----- tests/components/mqtt/test_button.py | 14 +------- tests/components/mqtt/test_camera.py | 8 ----- tests/components/mqtt/test_climate.py | 9 +---- tests/components/mqtt/test_cover.py | 8 ----- tests/components/mqtt/test_device_tracker.py | 10 +----- tests/components/mqtt/test_device_trigger.py | 12 ------- tests/components/mqtt/test_diagnostics.py | 13 +------ tests/components/mqtt/test_discovery.py | 35 ++----------------- tests/components/mqtt/test_event.py | 9 +---- tests/components/mqtt/test_fan.py | 8 ----- tests/components/mqtt/test_humidifier.py | 8 ----- tests/components/mqtt/test_image.py | 9 +---- tests/components/mqtt/test_init.py | 26 -------------- tests/components/mqtt/test_lawn_mower.py | 14 +------- tests/components/mqtt/test_legacy_vacuum.py | 9 ----- tests/components/mqtt/test_light.py | 15 +------- tests/components/mqtt/test_light_json.py | 8 ----- tests/components/mqtt/test_light_template.py | 8 ----- tests/components/mqtt/test_lock.py | 8 ----- tests/components/mqtt/test_mixins.py | 4 --- tests/components/mqtt/test_number.py | 8 ----- tests/components/mqtt/test_scene.py | 9 +---- tests/components/mqtt/test_select.py | 14 +------- tests/components/mqtt/test_sensor.py | 8 ----- tests/components/mqtt/test_siren.py | 8 ----- tests/components/mqtt/test_subscription.py | 9 +---- tests/components/mqtt/test_switch.py | 8 ----- tests/components/mqtt/test_tag.py | 8 ----- tests/components/mqtt/test_text.py | 14 +------- tests/components/mqtt/test_trigger.py | 9 +---- tests/components/mqtt/test_update.py | 15 +------- tests/components/mqtt/test_util.py | 2 -- tests/components/mqtt/test_vacuum.py | 9 +---- tests/components/mqtt/test_valve.py | 8 ----- tests/components/mqtt/test_water_heater.py | 9 +---- tests/conftest.py | 3 +- 40 files changed, 20 insertions(+), 403 deletions(-) diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index 397e530cb4b..3b34ef79291 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -84,7 +84,6 @@ from .const import ( # noqa: F401 DOMAIN, MQTT_CONNECTED, MQTT_DISCONNECTED, - PLATFORMS, RELOADABLE_PLATFORMS, TEMPLATE_ERRORS, ) diff --git a/homeassistant/components/mqtt/const.py b/homeassistant/components/mqtt/const.py index 7f97910961d..82320cd2f11 100644 --- a/homeassistant/components/mqtt/const.py +++ b/homeassistant/components/mqtt/const.py @@ -142,34 +142,6 @@ MQTT_DISCONNECTED = "mqtt_disconnected" PAYLOAD_EMPTY_JSON = "{}" PAYLOAD_NONE = "None" -PLATFORMS = [ - Platform.ALARM_CONTROL_PANEL, - Platform.BINARY_SENSOR, - Platform.BUTTON, - Platform.CAMERA, - Platform.CLIMATE, - Platform.COVER, - Platform.DEVICE_TRACKER, - Platform.EVENT, - Platform.FAN, - Platform.HUMIDIFIER, - Platform.IMAGE, - Platform.LAWN_MOWER, - Platform.LIGHT, - Platform.LOCK, - Platform.NUMBER, - Platform.SCENE, - Platform.SELECT, - Platform.SENSOR, - Platform.SIREN, - Platform.SWITCH, - Platform.TEXT, - Platform.UPDATE, - Platform.VACUUM, - Platform.VALVE, - Platform.WATER_HEATER, -] - RELOADABLE_PLATFORMS = [ Platform.ALARM_CONTROL_PANEL, Platform.BINARY_SENSOR, diff --git a/tests/components/mqtt/test_alarm_control_panel.py b/tests/components/mqtt/test_alarm_control_panel.py index dfe8d21a23b..055724a4659 100644 --- a/tests/components/mqtt/test_alarm_control_panel.py +++ b/tests/components/mqtt/test_alarm_control_panel.py @@ -35,7 +35,6 @@ from homeassistant.const import ( STATE_ALARM_PENDING, STATE_ALARM_TRIGGERED, STATE_UNKNOWN, - Platform, ) from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError @@ -135,15 +134,6 @@ DEFAULT_CONFIG_REMOTE_CODE_TEXT = { } -@pytest.fixture(autouse=True) -def alarm_control_panel_platform_only(): - """Only setup the alarm_control_panel platform to speed up tests.""" - with patch( - "homeassistant.components.mqtt.PLATFORMS", [Platform.ALARM_CONTROL_PANEL] - ): - yield - - @pytest.mark.parametrize( ("hass_config", "valid"), [ diff --git a/tests/components/mqtt/test_binary_sensor.py b/tests/components/mqtt/test_binary_sensor.py index c9c76bff67c..995aadd7dba 100644 --- a/tests/components/mqtt/test_binary_sensor.py +++ b/tests/components/mqtt/test_binary_sensor.py @@ -18,7 +18,6 @@ from homeassistant.const import ( STATE_ON, STATE_UNAVAILABLE, STATE_UNKNOWN, - Platform, ) from homeassistant.core import HomeAssistant, State, callback from homeassistant.helpers.typing import ConfigType @@ -72,13 +71,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def binary_sensor_platform_only(): - """Only setup the binary_sensor platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BINARY_SENSOR]): - yield - - @pytest.mark.parametrize( "hass_config", [ diff --git a/tests/components/mqtt/test_button.py b/tests/components/mqtt/test_button.py index fd070e0dd11..3d5d295d4d4 100644 --- a/tests/components/mqtt/test_button.py +++ b/tests/components/mqtt/test_button.py @@ -7,12 +7,7 @@ from unittest.mock import patch import pytest from homeassistant.components import button, mqtt -from homeassistant.const import ( - ATTR_ENTITY_ID, - ATTR_FRIENDLY_NAME, - STATE_UNKNOWN, - Platform, -) +from homeassistant.const import ATTR_ENTITY_ID, ATTR_FRIENDLY_NAME, STATE_UNKNOWN from homeassistant.core import HomeAssistant from .test_common import ( @@ -50,13 +45,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def button_platform_only(): - """Only setup the button platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BUTTON]): - yield - - @pytest.mark.freeze_time("2021-11-08 13:31:44+00:00") @pytest.mark.parametrize( "hass_config", diff --git a/tests/components/mqtt/test_camera.py b/tests/components/mqtt/test_camera.py index e0c781701ab..fb0107d6780 100644 --- a/tests/components/mqtt/test_camera.py +++ b/tests/components/mqtt/test_camera.py @@ -9,7 +9,6 @@ import pytest from homeassistant.components import camera, mqtt from homeassistant.components.mqtt.camera import MQTT_CAMERA_ATTRIBUTES_BLOCKED -from homeassistant.const import Platform from homeassistant.core import HomeAssistant from .test_common import ( @@ -49,13 +48,6 @@ from tests.typing import ( DEFAULT_CONFIG = {mqtt.DOMAIN: {camera.DOMAIN: {"name": "test", "topic": "test_topic"}}} -@pytest.fixture(autouse=True) -def camera_platform_only(): - """Only setup the camera platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.CAMERA]): - yield - - @pytest.mark.parametrize( "hass_config", [{mqtt.DOMAIN: {camera.DOMAIN: {"topic": "test/camera", "name": "Test Camera"}}}], diff --git a/tests/components/mqtt/test_climate.py b/tests/components/mqtt/test_climate.py index 249715a9085..1224fce098d 100644 --- a/tests/components/mqtt/test_climate.py +++ b/tests/components/mqtt/test_climate.py @@ -32,7 +32,7 @@ from homeassistant.components.mqtt.climate import ( MQTT_CLIMATE_ATTRIBUTES_BLOCKED, VALUE_TEMPLATE_KEYS, ) -from homeassistant.const import ATTR_TEMPERATURE, Platform, UnitOfTemperature +from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.exceptions import ServiceValidationError @@ -99,13 +99,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def climate_platform_only(): - """Only setup the climate platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.CLIMATE]): - yield - - @pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) async def test_setup_params( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator diff --git a/tests/components/mqtt/test_cover.py b/tests/components/mqtt/test_cover.py index 793e47f1a17..b2b1d1bd9c6 100644 --- a/tests/components/mqtt/test_cover.py +++ b/tests/components/mqtt/test_cover.py @@ -43,7 +43,6 @@ from homeassistant.const import ( STATE_OPEN, STATE_OPENING, STATE_UNKNOWN, - Platform, ) from homeassistant.core import HomeAssistant @@ -86,13 +85,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def cover_platform_only(): - """Only setup the cover platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.COVER]): - yield - - @pytest.mark.parametrize( "hass_config", [ diff --git a/tests/components/mqtt/test_device_tracker.py b/tests/components/mqtt/test_device_tracker.py index 1d975b06f75..680c48d13c7 100644 --- a/tests/components/mqtt/test_device_tracker.py +++ b/tests/components/mqtt/test_device_tracker.py @@ -1,14 +1,13 @@ """The tests for the MQTT device_tracker platform.""" from datetime import UTC, datetime -from unittest.mock import patch from freezegun.api import FrozenDateTimeFactory import pytest from homeassistant.components import device_tracker, mqtt 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 from homeassistant.core import HomeAssistant from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.setup import async_setup_component @@ -37,13 +36,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def device_tracker_platform_only(): - """Only setup the device_tracker platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.DEVICE_TRACKER]): - yield - - async def test_discover_device_tracker( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, diff --git a/tests/components/mqtt/test_device_trigger.py b/tests/components/mqtt/test_device_trigger.py index e4e3149559a..4f4c9a18bd9 100644 --- a/tests/components/mqtt/test_device_trigger.py +++ b/tests/components/mqtt/test_device_trigger.py @@ -1,7 +1,6 @@ """The tests for MQTT device triggers.""" import json -from unittest.mock import patch import pytest from pytest_unordered import unordered @@ -9,7 +8,6 @@ from pytest_unordered import unordered import homeassistant.components.automation as automation from homeassistant.components.device_automation import DeviceAutomationType from homeassistant.components.mqtt import _LOGGER, DOMAIN, debug_info -from homeassistant.const import Platform from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import device_registry as dr @@ -37,16 +35,6 @@ def calls(hass: HomeAssistant) -> list[ServiceCall]: return async_mock_service(hass, "test", "automation") -@pytest.fixture(autouse=True) -def binary_sensor_and_sensor_only(): - """Only setup the binary_sensor and sensor platform to speed up tests.""" - with patch( - "homeassistant.components.mqtt.PLATFORMS", - [Platform.BINARY_SENSOR, Platform.SENSOR], - ): - yield - - async def test_get_triggers( hass: HomeAssistant, device_registry: dr.DeviceRegistry, diff --git a/tests/components/mqtt/test_diagnostics.py b/tests/components/mqtt/test_diagnostics.py index e09b32de2d4..9ca903b88b7 100644 --- a/tests/components/mqtt/test_diagnostics.py +++ b/tests/components/mqtt/test_diagnostics.py @@ -1,12 +1,11 @@ """Test MQTT diagnostics.""" import json -from unittest.mock import ANY, patch +from unittest.mock import ANY import pytest from homeassistant.components import mqtt -from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import device_registry as dr @@ -23,16 +22,6 @@ default_config = { } -@pytest.fixture(autouse=True) -def device_tracker_sensor_only(): - """Only setup the device_tracker and sensor platforms to speed up tests.""" - with patch( - "homeassistant.components.mqtt.PLATFORMS", - [Platform.DEVICE_TRACKER, Platform.SENSOR], - ): - yield - - async def test_entry_diagnostics( hass: HomeAssistant, device_registry: dr.DeviceRegistry, diff --git a/tests/components/mqtt/test_discovery.py b/tests/components/mqtt/test_discovery.py index 6121e1dc15e..e1fbb95791e 100644 --- a/tests/components/mqtt/test_discovery.py +++ b/tests/components/mqtt/test_discovery.py @@ -69,7 +69,6 @@ async def test_subscribing_config_topic( assert discovery_topic + "/+/+/+/config" in topics -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BINARY_SENSOR]) @pytest.mark.parametrize( ("topic", "log"), [ @@ -103,7 +102,6 @@ async def test_invalid_topic( caplog.clear() -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BINARY_SENSOR]) async def test_invalid_json( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -124,7 +122,9 @@ async def test_invalid_json( assert not mock_dispatcher_send.called -@pytest.mark.parametrize("domain", [*list(mqtt.PLATFORMS), "device_automation", "tag"]) +@pytest.mark.parametrize( + "domain", ["tag", "device_automation", Platform.SENSOR, Platform.LIGHT] +) @pytest.mark.no_fail_on_log_exception async def test_discovery_schema_error( hass: HomeAssistant, @@ -147,7 +147,6 @@ async def test_discovery_schema_error( assert "AttributeError: Attribute abc not found" in caplog.text -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.ALARM_CONTROL_PANEL]) async def test_invalid_config( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -191,7 +190,6 @@ async def test_only_valid_components( assert not mock_dispatcher_send.called -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BINARY_SENSOR]) async def test_correct_config_discovery( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -212,7 +210,6 @@ async def test_correct_config_discovery( assert ("binary_sensor", "bla") in hass.data["mqtt"].discovery_already_discovered -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BINARY_SENSOR]) async def test_discovery_integration_info( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -265,7 +262,6 @@ async def test_discovery_integration_info( '{ "name": "Beer", "state_topic": "test-topic", "o": {"sw": "bla2mqtt"} }', ], ) -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BINARY_SENSOR]) async def test_discovery_with_invalid_integration_info( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -289,7 +285,6 @@ async def test_discovery_with_invalid_integration_info( ) -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.FAN]) async def test_discover_fan( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -310,7 +305,6 @@ async def test_discover_fan( assert ("fan", "bla") in hass.data["mqtt"].discovery_already_discovered -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.CLIMATE]) async def test_discover_climate( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -334,7 +328,6 @@ async def test_discover_climate( assert ("climate", "bla") in hass.data["mqtt"].discovery_already_discovered -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.ALARM_CONTROL_PANEL]) async def test_discover_alarm_control_panel( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -525,7 +518,6 @@ async def test_discovery_with_object_id( assert (domain, "object bla") in hass.data["mqtt"].discovery_already_discovered -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BINARY_SENSOR]) async def test_discovery_incl_nodeid( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -548,7 +540,6 @@ async def test_discovery_incl_nodeid( ].discovery_already_discovered -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BINARY_SENSOR]) async def test_non_duplicate_discovery( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -577,7 +568,6 @@ async def test_non_duplicate_discovery( assert "Component has already been discovered: binary_sensor bla" in caplog.text -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BINARY_SENSOR]) async def test_removal( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -599,7 +589,6 @@ async def test_removal( assert state is None -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BINARY_SENSOR]) async def test_rediscover( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -630,7 +619,6 @@ async def test_rediscover( assert state is not None -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BINARY_SENSOR]) async def test_rapid_rediscover( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -683,7 +671,6 @@ async def test_rapid_rediscover( assert events[4].data["old_state"] is None -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BINARY_SENSOR]) async def test_rapid_rediscover_unique( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -746,7 +733,6 @@ async def test_rapid_rediscover_unique( assert events[3].data["old_state"] is None -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BINARY_SENSOR]) async def test_rapid_reconfigure( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -802,7 +788,6 @@ async def test_rapid_reconfigure( assert events[2].data["new_state"].attributes["friendly_name"] == "Wine" -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BINARY_SENSOR]) async def test_duplicate_removal( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -888,7 +873,6 @@ async def test_cleanup_device( ) -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SENSOR]) async def test_cleanup_device_mqtt( hass: HomeAssistant, device_registry: dr.DeviceRegistry, @@ -934,7 +918,6 @@ async def test_cleanup_device_mqtt( mqtt_mock.async_publish.assert_not_called() -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SENSOR]) async def test_cleanup_device_multiple_config_entries( hass: HomeAssistant, hass_ws_client: WebSocketGenerator, @@ -1126,7 +1109,6 @@ async def test_cleanup_device_multiple_config_entries_mqtt( mqtt_mock.async_publish.assert_not_called() -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SWITCH]) async def test_discovery_expansion( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -1189,7 +1171,6 @@ async def test_discovery_expansion( assert state and state.state == STATE_UNAVAILABLE -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SWITCH]) async def test_discovery_expansion_2( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -1234,7 +1215,6 @@ async def test_discovery_expansion_2( assert state.state == STATE_UNKNOWN -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SWITCH]) async def test_discovery_expansion_3( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -1319,7 +1299,6 @@ async def test_discovery_expansion_without_encoding_and_value_template_1( assert state and state.state == STATE_UNAVAILABLE -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SWITCH]) async def test_discovery_expansion_without_encoding_and_value_template_2( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -1433,7 +1412,6 @@ async def test_missing_discover_abbreviations( assert not missing -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SWITCH]) async def test_no_implicit_state_topic_switch( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -1458,7 +1436,6 @@ async def test_no_implicit_state_topic_switch( assert state and state.state == STATE_UNKNOWN -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BINARY_SENSOR]) @pytest.mark.parametrize( "mqtt_config_entry_data", [ @@ -1490,7 +1467,6 @@ async def test_complex_discovery_topic_prefix( ].discovery_already_discovered -@patch("homeassistant.components.mqtt.PLATFORMS", []) @patch("homeassistant.components.mqtt.client.INITIAL_SUBSCRIBE_COOLDOWN", 0.0) @patch("homeassistant.components.mqtt.client.SUBSCRIBE_COOLDOWN", 0.0) @patch("homeassistant.components.mqtt.client.UNSUBSCRIBE_COOLDOWN", 0.0) @@ -1540,7 +1516,6 @@ async def test_mqtt_integration_discovery_subscribe_unsubscribe( mqtt_client_mock.unsubscribe.assert_called_once_with(["comp/discovery/#"]) -@patch("homeassistant.components.mqtt.PLATFORMS", []) @patch("homeassistant.components.mqtt.client.INITIAL_SUBSCRIBE_COOLDOWN", 0.0) @patch("homeassistant.components.mqtt.client.SUBSCRIBE_COOLDOWN", 0.0) @patch("homeassistant.components.mqtt.client.UNSUBSCRIBE_COOLDOWN", 0.0) @@ -1583,7 +1558,6 @@ async def test_mqtt_discovery_unsubscribe_once( mqtt_client_mock.unsubscribe.assert_called_once_with(["comp/discovery/#"]) -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SENSOR]) async def test_clear_config_topic_disabled_entity( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -1658,7 +1632,6 @@ async def test_clear_config_topic_disabled_entity( ) -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SENSOR]) async def test_clean_up_registry_monitoring( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -1713,7 +1686,6 @@ async def test_clean_up_registry_monitoring( assert len(hooks) == 0 -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SENSOR]) async def test_unique_id_collission_has_priority( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -1760,7 +1732,6 @@ async def test_unique_id_collission_has_priority( assert entity_registry.async_get("sensor.abc123_sbfspot_12345_2") is None -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SENSOR]) async def test_update_with_bad_config_not_breaks_discovery( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_event.py b/tests/components/mqtt/test_event.py index bcfbb1d8d40..488612a0fa3 100644 --- a/tests/components/mqtt/test_event.py +++ b/tests/components/mqtt/test_event.py @@ -9,7 +9,7 @@ import pytest from homeassistant.components import event, mqtt from homeassistant.components.mqtt.event import MQTT_EVENT_ATTRIBUTES_BLOCKED -from homeassistant.const import STATE_UNKNOWN, Platform +from homeassistant.const import STATE_UNKNOWN from homeassistant.core import HomeAssistant from homeassistant.helpers import device_registry as dr @@ -65,13 +65,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def event_platform_only(): - """Only setup the event platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.EVENT]): - yield - - @pytest.mark.freeze_time("2023-08-01 00:00:00+00:00") @pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) async def test_setting_event_value_via_mqtt_message( diff --git a/tests/components/mqtt/test_fan.py b/tests/components/mqtt/test_fan.py index 493e1e5ddf7..0dbfa3037b2 100644 --- a/tests/components/mqtt/test_fan.py +++ b/tests/components/mqtt/test_fan.py @@ -33,7 +33,6 @@ from homeassistant.const import ( STATE_OFF, STATE_ON, STATE_UNKNOWN, - Platform, ) from homeassistant.core import HomeAssistant @@ -83,13 +82,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def fan_platform_only(): - """Only setup the fan platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.FAN]): - yield - - @pytest.mark.parametrize("hass_config", [{mqtt.DOMAIN: {fan.DOMAIN: {"name": "test"}}}]) async def test_fail_setup_if_no_command_topic( hass: HomeAssistant, diff --git a/tests/components/mqtt/test_humidifier.py b/tests/components/mqtt/test_humidifier.py index 0778d36f873..75baca046bd 100644 --- a/tests/components/mqtt/test_humidifier.py +++ b/tests/components/mqtt/test_humidifier.py @@ -34,7 +34,6 @@ from homeassistant.const import ( STATE_OFF, STATE_ON, STATE_UNKNOWN, - Platform, ) from homeassistant.core import HomeAssistant @@ -84,13 +83,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def humidifer_platform_only(): - """Only setup the humidifer platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.HUMIDIFIER]): - yield - - async def async_turn_on( hass: HomeAssistant, entity_id=ENTITY_MATCH_ALL, diff --git a/tests/components/mqtt/test_image.py b/tests/components/mqtt/test_image.py index aa17b878e1c..2f1676c0c03 100644 --- a/tests/components/mqtt/test_image.py +++ b/tests/components/mqtt/test_image.py @@ -11,7 +11,7 @@ import pytest import respx from homeassistant.components import image, mqtt -from homeassistant.const import STATE_UNAVAILABLE, STATE_UNKNOWN, Platform +from homeassistant.const import STATE_UNAVAILABLE, STATE_UNKNOWN from homeassistant.core import HomeAssistant from .test_common import ( @@ -54,13 +54,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def image_platform_only(): - """Only setup the image platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.IMAGE]): - yield - - @pytest.mark.freeze_time("2023-04-01 00:00:00+00:00") @pytest.mark.parametrize( "hass_config", diff --git a/tests/components/mqtt/test_init.py b/tests/components/mqtt/test_init.py index 60a909395f1..71b103c8bcc 100644 --- a/tests/components/mqtt/test_init.py +++ b/tests/components/mqtt/test_init.py @@ -1,7 +1,6 @@ """The tests for the MQTT component.""" import asyncio -from collections.abc import Generator from copy import deepcopy from datetime import datetime, timedelta from functools import partial @@ -32,7 +31,6 @@ from homeassistant.const import ( SERVICE_RELOAD, STATE_UNAVAILABLE, STATE_UNKNOWN, - Platform, UnitOfTemperature, ) import homeassistant.core as ha @@ -92,16 +90,6 @@ class RecordCallsPartial(partial[Any]): __name__ = "RecordCallPartialTest" -@pytest.fixture(autouse=True) -def sensor_platforms_only() -> Generator[None, None, None]: - """Only setup the sensor platforms to speed up tests.""" - with patch( - "homeassistant.components.mqtt.PLATFORMS", - [Platform.SENSOR, Platform.BINARY_SENSOR], - ): - yield - - @pytest.fixture(autouse=True) def mock_storage(hass_storage: dict[str, Any]) -> None: """Autouse hass_storage for the TestCase tests.""" @@ -168,7 +156,6 @@ async def test_mqtt_disconnects_on_home_assistant_stop( assert mqtt_client_mock.loop_stop.call_count == 1 -@patch("homeassistant.components.mqtt.PLATFORMS", []) async def test_mqtt_await_ack_at_disconnect( hass: HomeAssistant, ) -> None: @@ -312,7 +299,6 @@ async def test_command_template_value(hass: HomeAssistant) -> None: assert cmd_tpl.async_render(None, variables=variables) == "beer" -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SELECT]) @pytest.mark.parametrize( "config", [ @@ -2162,7 +2148,6 @@ async def test_handle_message_callback( } ], ) -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.LIGHT]) async def test_setup_manual_mqtt_with_platform_key( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -2177,7 +2162,6 @@ async def test_setup_manual_mqtt_with_platform_key( @pytest.mark.parametrize("hass_config", [{mqtt.DOMAIN: {"light": {"name": "test"}}}]) -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.LIGHT]) async def test_setup_manual_mqtt_with_invalid_config( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -2188,7 +2172,6 @@ async def test_setup_manual_mqtt_with_invalid_config( assert "required key not provided" in caplog.text -@patch("homeassistant.components.mqtt.PLATFORMS", []) @pytest.mark.parametrize( ("mqtt_config_entry_data", "protocol"), [ @@ -2229,7 +2212,6 @@ async def test_setup_mqtt_client_protocol( @patch("homeassistant.components.mqtt.client.TIMEOUT_ACK", 0.2) -@patch("homeassistant.components.mqtt.PLATFORMS", []) async def test_handle_mqtt_timeout_on_callback( hass: HomeAssistant, caplog: pytest.LogCaptureFixture ) -> None: @@ -2300,7 +2282,6 @@ async def test_setup_raises_config_entry_not_ready_if_no_connect_broker( ({"broker": "test-broker", "certificate": "auto", "tls_insecure": True}, True), ], ) -@patch("homeassistant.components.mqtt.PLATFORMS", []) async def test_setup_uses_certificate_on_certificate_set_to_auto_and_insecure( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -2921,7 +2902,6 @@ async def test_mqtt_ws_get_device_debug_info( assert response["result"] == expected_result -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.CAMERA]) async def test_mqtt_ws_get_device_debug_info_binary( hass: HomeAssistant, device_registry: dr.DeviceRegistry, @@ -3575,7 +3555,6 @@ async def test_unload_config_entry( assert "No ACK from MQTT server" not in caplog.text -@patch("homeassistant.components.mqtt.PLATFORMS", []) async def test_publish_or_subscribe_without_valid_config_entry( hass: HomeAssistant, record_calls: MessageCallbackType ) -> None: @@ -3588,10 +3567,6 @@ async def test_publish_or_subscribe_without_valid_config_entry( await mqtt.async_subscribe(hass, "some-topic", record_calls, qos=0) -@patch( - "homeassistant.components.mqtt.PLATFORMS", - [Platform.ALARM_CONTROL_PANEL, Platform.LIGHT], -) @pytest.mark.parametrize( "hass_config", [ @@ -3666,7 +3641,6 @@ async def test_disabling_and_enabling_entry( assert hass.states.get("alarm_control_panel.test") is not None -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.LIGHT]) @pytest.mark.parametrize( ("hass_config", "unique"), [ diff --git a/tests/components/mqtt/test_lawn_mower.py b/tests/components/mqtt/test_lawn_mower.py index a6e338c17da..a95c613cdc4 100644 --- a/tests/components/mqtt/test_lawn_mower.py +++ b/tests/components/mqtt/test_lawn_mower.py @@ -16,12 +16,7 @@ from homeassistant.components.lawn_mower import ( LawnMowerEntityFeature, ) from homeassistant.components.mqtt.lawn_mower import MQTT_LAWN_MOWER_ATTRIBUTES_BLOCKED -from homeassistant.const import ( - ATTR_ASSUMED_STATE, - ATTR_ENTITY_ID, - STATE_UNKNOWN, - Platform, -) +from homeassistant.const import ATTR_ASSUMED_STATE, ATTR_ENTITY_ID, STATE_UNKNOWN from homeassistant.core import HomeAssistant, State from .test_common import ( @@ -79,13 +74,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def lawn_mower_platform_only(): - """Only setup the lawn_mower platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.LAWN_MOWER]): - yield - - @pytest.mark.parametrize( "hass_config", [ diff --git a/tests/components/mqtt/test_legacy_vacuum.py b/tests/components/mqtt/test_legacy_vacuum.py index 3e88d4a4335..e4f5e3cd481 100644 --- a/tests/components/mqtt/test_legacy_vacuum.py +++ b/tests/components/mqtt/test_legacy_vacuum.py @@ -5,12 +5,10 @@ # cleanup is planned with HA Core 2025.2 import json -from unittest.mock import patch import pytest from homeassistant.components import mqtt, vacuum -from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.helpers.typing import DiscoveryInfoType @@ -20,13 +18,6 @@ from tests.typing import MqttMockHAClientGenerator DEFAULT_CONFIG = {mqtt.DOMAIN: {vacuum.DOMAIN: {"name": "test"}}} -@pytest.fixture(autouse=True) -def vacuum_platform_only(): - """Only setup the vacuum platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.VACUUM]): - yield - - @pytest.mark.parametrize( ("hass_config", "removed"), [ diff --git a/tests/components/mqtt/test_light.py b/tests/components/mqtt/test_light.py index 749b5c5403a..492bc6806da 100644 --- a/tests/components/mqtt/test_light.py +++ b/tests/components/mqtt/test_light.py @@ -190,13 +190,7 @@ from homeassistant.components.mqtt.light.schema_basic import ( VALUE_TEMPLATE_KEYS, ) from homeassistant.components.mqtt.models import PublishPayloadType -from homeassistant.const import ( - ATTR_ASSUMED_STATE, - STATE_OFF, - STATE_ON, - STATE_UNKNOWN, - Platform, -) +from homeassistant.const import ATTR_ASSUMED_STATE, STATE_OFF, STATE_ON, STATE_UNKNOWN from homeassistant.core import HomeAssistant, State from .test_common import ( @@ -239,13 +233,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def light_platform_only(): - """Only setup the light platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.LIGHT]): - yield - - @pytest.mark.parametrize( "hass_config", [{mqtt.DOMAIN: {light.DOMAIN: {"name": "test"}}}] ) diff --git a/tests/components/mqtt/test_light_json.py b/tests/components/mqtt/test_light_json.py index 796ee9ef9d2..8adbf05e46c 100644 --- a/tests/components/mqtt/test_light_json.py +++ b/tests/components/mqtt/test_light_json.py @@ -96,7 +96,6 @@ from homeassistant.const import ( STATE_OFF, STATE_ON, STATE_UNKNOWN, - Platform, ) from homeassistant.core import HomeAssistant, State from homeassistant.helpers.json import json_dumps @@ -170,13 +169,6 @@ COLOR_MODES_CONFIG = { } -@pytest.fixture(autouse=True) -def light_platform_only(): - """Only setup the light platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.LIGHT]): - yield - - class JsonValidator: """Helper to compare JSON.""" diff --git a/tests/components/mqtt/test_light_template.py b/tests/components/mqtt/test_light_template.py index f562a11bb95..da6195fa32e 100644 --- a/tests/components/mqtt/test_light_template.py +++ b/tests/components/mqtt/test_light_template.py @@ -42,7 +42,6 @@ from homeassistant.const import ( STATE_OFF, STATE_ON, STATE_UNKNOWN, - Platform, ) from homeassistant.core import HomeAssistant, State @@ -94,13 +93,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def light_platform_only(): - """Only setup the light platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.LIGHT]): - yield - - @pytest.mark.parametrize( "hass_config", [ diff --git a/tests/components/mqtt/test_lock.py b/tests/components/mqtt/test_lock.py index 5a794f6082e..a52d1ab42f4 100644 --- a/tests/components/mqtt/test_lock.py +++ b/tests/components/mqtt/test_lock.py @@ -24,7 +24,6 @@ from homeassistant.const import ( ATTR_ENTITY_ID, ATTR_SUPPORTED_FEATURES, STATE_UNKNOWN, - Platform, ) from homeassistant.core import HomeAssistant @@ -83,13 +82,6 @@ CONFIG_WITH_STATES = { } -@pytest.fixture(autouse=True) -def lock_platform_only(): - """Only setup the lock platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.LOCK]): - yield - - @pytest.mark.parametrize( ("hass_config", "payload", "lock_state"), [ diff --git a/tests/components/mqtt/test_mixins.py b/tests/components/mqtt/test_mixins.py index 7b4b10ad776..2bcd663c243 100644 --- a/tests/components/mqtt/test_mixins.py +++ b/tests/components/mqtt/test_mixins.py @@ -10,7 +10,6 @@ from homeassistant.const import ( ATTR_FRIENDLY_NAME, EVENT_HOMEASSISTANT_STARTED, EVENT_STATE_CHANGED, - Platform, ) from homeassistant.core import CoreState, HomeAssistant, callback from homeassistant.helpers import device_registry as dr, issue_registry as ir @@ -37,7 +36,6 @@ from tests.typing import MqttMockHAClientGenerator, MqttMockPahoClient } ], ) -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SENSOR]) async def test_availability_with_shared_state_topic( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, @@ -296,7 +294,6 @@ async def test_availability_with_shared_state_topic( "entity_name_startswith_device_name2", ], ) -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SENSOR]) @patch("homeassistant.components.mqtt.client.DISCOVERY_COOLDOWN", 0.0) async def test_default_entity_and_device_name( hass: HomeAssistant, @@ -340,7 +337,6 @@ async def test_default_entity_and_device_name( assert len(events) == 0 -@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BINARY_SENSOR]) async def test_name_attribute_is_set_or_not( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, diff --git a/tests/components/mqtt/test_number.py b/tests/components/mqtt/test_number.py index 40d7cd60df5..b0f9e79cb3e 100644 --- a/tests/components/mqtt/test_number.py +++ b/tests/components/mqtt/test_number.py @@ -26,7 +26,6 @@ from homeassistant.const import ( ATTR_ENTITY_ID, ATTR_MODE, ATTR_UNIT_OF_MEASUREMENT, - Platform, UnitOfTemperature, ) from homeassistant.core import HomeAssistant, State @@ -71,13 +70,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def number_platform_only(): - """Only setup the number platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.NUMBER]): - yield - - @pytest.mark.parametrize( ("hass_config", "device_class", "unit_of_measurement", "values"), [ diff --git a/tests/components/mqtt/test_scene.py b/tests/components/mqtt/test_scene.py index 67fd794c906..3e9eacd3be2 100644 --- a/tests/components/mqtt/test_scene.py +++ b/tests/components/mqtt/test_scene.py @@ -7,7 +7,7 @@ from unittest.mock import patch import pytest from homeassistant.components import mqtt, scene -from homeassistant.const import ATTR_ENTITY_ID, SERVICE_TURN_ON, STATE_UNKNOWN, Platform +from homeassistant.const import ATTR_ENTITY_ID, SERVICE_TURN_ON, STATE_UNKNOWN from homeassistant.core import HomeAssistant, State from .test_common import ( @@ -51,13 +51,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def scene_platform_only(): - """Only setup the scene platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SCENE]): - yield - - @pytest.mark.parametrize( "hass_config", [ diff --git a/tests/components/mqtt/test_select.py b/tests/components/mqtt/test_select.py index b50843951b1..e5e1352abb7 100644 --- a/tests/components/mqtt/test_select.py +++ b/tests/components/mqtt/test_select.py @@ -16,12 +16,7 @@ from homeassistant.components.select import ( DOMAIN as SELECT_DOMAIN, SERVICE_SELECT_OPTION, ) -from homeassistant.const import ( - ATTR_ASSUMED_STATE, - ATTR_ENTITY_ID, - STATE_UNKNOWN, - Platform, -) +from homeassistant.const import ATTR_ASSUMED_STATE, ATTR_ENTITY_ID, STATE_UNKNOWN from homeassistant.core import HomeAssistant, State from homeassistant.helpers.typing import ConfigType @@ -71,13 +66,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def select_platform_only(): - """Only setup the select platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SELECT]): - yield - - def _test_run_select_setup_params( topic: str, ) -> Generator[tuple[ConfigType, str], None]: diff --git a/tests/components/mqtt/test_sensor.py b/tests/components/mqtt/test_sensor.py index 0345b76c241..d88bd3a544a 100644 --- a/tests/components/mqtt/test_sensor.py +++ b/tests/components/mqtt/test_sensor.py @@ -17,7 +17,6 @@ from homeassistant.const import ( EVENT_STATE_CHANGED, STATE_UNAVAILABLE, STATE_UNKNOWN, - Platform, UnitOfTemperature, ) from homeassistant.core import Event, HomeAssistant, State, callback @@ -81,13 +80,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def sensor_platform_only(): - """Only setup the sensor platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SENSOR]): - yield - - @pytest.mark.parametrize( "hass_config", [ diff --git a/tests/components/mqtt/test_siren.py b/tests/components/mqtt/test_siren.py index c583c4dfe68..c2cb39cca0a 100644 --- a/tests/components/mqtt/test_siren.py +++ b/tests/components/mqtt/test_siren.py @@ -17,7 +17,6 @@ from homeassistant.const import ( STATE_OFF, STATE_ON, STATE_UNKNOWN, - Platform, ) from homeassistant.core import HomeAssistant @@ -60,13 +59,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def siren_platform_only(): - """Only setup the siren platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SIREN]): - yield - - async def async_turn_on( hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL, diff --git a/tests/components/mqtt/test_subscription.py b/tests/components/mqtt/test_subscription.py index 5196c58192d..54acc935f1d 100644 --- a/tests/components/mqtt/test_subscription.py +++ b/tests/components/mqtt/test_subscription.py @@ -1,6 +1,6 @@ """The tests for the MQTT subscription component.""" -from unittest.mock import ANY, patch +from unittest.mock import ANY import pytest @@ -15,13 +15,6 @@ from tests.common import async_fire_mqtt_message from tests.typing import MqttMockHAClientGenerator -@pytest.fixture(autouse=True) -def no_platforms(): - """Skip platform setup to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", []): - yield - - async def test_subscribe_topics( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, diff --git a/tests/components/mqtt/test_switch.py b/tests/components/mqtt/test_switch.py index fff96b290ff..b497d4a2f52 100644 --- a/tests/components/mqtt/test_switch.py +++ b/tests/components/mqtt/test_switch.py @@ -13,7 +13,6 @@ from homeassistant.const import ( STATE_OFF, STATE_ON, STATE_UNKNOWN, - Platform, ) from homeassistant.core import HomeAssistant, State @@ -57,13 +56,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def switch_platform_only(): - """Only setup the switch platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.SWITCH]): - yield - - @pytest.mark.parametrize( ("hass_config", "device_class"), [ diff --git a/tests/components/mqtt/test_tag.py b/tests/components/mqtt/test_tag.py index d374d816a0d..9a0da989216 100644 --- a/tests/components/mqtt/test_tag.py +++ b/tests/components/mqtt/test_tag.py @@ -9,7 +9,6 @@ import pytest from homeassistant.components.device_automation import DeviceAutomationType from homeassistant.components.mqtt.const import DOMAIN as MQTT_DOMAIN -from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import device_registry as dr from homeassistant.setup import async_setup_component @@ -47,13 +46,6 @@ DEFAULT_TAG_SCAN_JSON = ( ) -@pytest.fixture(autouse=True) -def binary_sensor_only() -> Generator[None, None, None]: - """Only setup the binary_sensor platform to speed up test.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.BINARY_SENSOR]): - yield - - @pytest.fixture def tag_mock() -> Generator[AsyncMock, None, None]: """Fixture to mock tag.""" diff --git a/tests/components/mqtt/test_text.py b/tests/components/mqtt/test_text.py index 8966ea9de56..63c69d3cfac 100644 --- a/tests/components/mqtt/test_text.py +++ b/tests/components/mqtt/test_text.py @@ -8,12 +8,7 @@ from unittest.mock import patch import pytest from homeassistant.components import mqtt, text -from homeassistant.const import ( - ATTR_ASSUMED_STATE, - ATTR_ENTITY_ID, - STATE_UNKNOWN, - Platform, -) +from homeassistant.const import ATTR_ASSUMED_STATE, ATTR_ENTITY_ID, STATE_UNKNOWN from homeassistant.core import HomeAssistant from .test_common import ( @@ -55,13 +50,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def text_platform_only(): - """Only setup the text platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.TEXT]): - yield - - async def async_set_value( hass: HomeAssistant, entity_id: str, value: str | None ) -> None: diff --git a/tests/components/mqtt/test_trigger.py b/tests/components/mqtt/test_trigger.py index 756b8d022e0..90a39bfd4fb 100644 --- a/tests/components/mqtt/test_trigger.py +++ b/tests/components/mqtt/test_trigger.py @@ -1,6 +1,6 @@ """The tests for the MQTT automation.""" -from unittest.mock import ANY, patch +from unittest.mock import ANY import pytest @@ -23,13 +23,6 @@ def calls(hass: HomeAssistant): return async_mock_service(hass, "test", "automation") -@pytest.fixture(autouse=True) -def no_platforms(): - """Skip platform setup to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", []): - yield - - @pytest.fixture(autouse=True) async def setup_comp(hass: HomeAssistant, mqtt_mock_entry): """Initialize components.""" diff --git a/tests/components/mqtt/test_update.py b/tests/components/mqtt/test_update.py index 2fcfbb59952..bb80a0c274f 100644 --- a/tests/components/mqtt/test_update.py +++ b/tests/components/mqtt/test_update.py @@ -7,13 +7,7 @@ import pytest from homeassistant.components import mqtt, update from homeassistant.components.update import DOMAIN as UPDATE_DOMAIN, SERVICE_INSTALL -from homeassistant.const import ( - ATTR_ENTITY_ID, - STATE_OFF, - STATE_ON, - STATE_UNKNOWN, - Platform, -) +from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON, STATE_UNKNOWN from homeassistant.core import HomeAssistant from .test_common import ( @@ -58,13 +52,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def update_platform_only(): - """Only setup the update platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.UPDATE]): - yield - - @pytest.mark.parametrize( ("hass_config", "device_class"), [ diff --git a/tests/components/mqtt/test_util.py b/tests/components/mqtt/test_util.py index 14153b44d87..0b8d7002319 100644 --- a/tests/components/mqtt/test_util.py +++ b/tests/components/mqtt/test_util.py @@ -134,7 +134,6 @@ async def test_return_default_get_file_path( assert await hass.async_add_executor_job(_get_file_path, tempdir) -@patch("homeassistant.components.mqtt.PLATFORMS", []) async def test_waiting_for_client_not_loaded( hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient, @@ -172,7 +171,6 @@ async def test_waiting_for_client_not_loaded( unsub() -@patch("homeassistant.components.mqtt.PLATFORMS", []) async def test_waiting_for_client_loaded( hass: HomeAssistant, mqtt_mock: MqttMockHAClient, diff --git a/tests/components/mqtt/test_vacuum.py b/tests/components/mqtt/test_vacuum.py index a862ba3143d..7563752b2d7 100644 --- a/tests/components/mqtt/test_vacuum.py +++ b/tests/components/mqtt/test_vacuum.py @@ -32,7 +32,7 @@ from homeassistant.components.vacuum import ( STATE_CLEANING, STATE_DOCKED, ) -from homeassistant.const import CONF_NAME, ENTITY_MATCH_ALL, STATE_UNKNOWN, Platform +from homeassistant.const import CONF_NAME, ENTITY_MATCH_ALL, STATE_UNKNOWN from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError @@ -103,13 +103,6 @@ CONFIG_ALL_SERVICES = help_custom_config( ) -@pytest.fixture(autouse=True) -def vacuum_platform_only(): - """Only setup the vacuum platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.VACUUM]): - yield - - @pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) async def test_default_supported_features( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator diff --git a/tests/components/mqtt/test_valve.py b/tests/components/mqtt/test_valve.py index bc0676f5aa4..7fd9b10c005 100644 --- a/tests/components/mqtt/test_valve.py +++ b/tests/components/mqtt/test_valve.py @@ -27,7 +27,6 @@ from homeassistant.const import ( STATE_OPEN, STATE_OPENING, STATE_UNKNOWN, - Platform, ) from homeassistant.core import HomeAssistant @@ -87,13 +86,6 @@ DEFAULT_CONFIG_REPORTS_POSITION = { } -@pytest.fixture(autouse=True) -def valve_platform_only(): - """Only setup the valve platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.VALVE]): - yield - - @pytest.mark.parametrize( "hass_config", [ diff --git a/tests/components/mqtt/test_water_heater.py b/tests/components/mqtt/test_water_heater.py index 945a2296435..ee0aa1c0949 100644 --- a/tests/components/mqtt/test_water_heater.py +++ b/tests/components/mqtt/test_water_heater.py @@ -25,7 +25,7 @@ from homeassistant.components.water_heater import ( STATE_PERFORMANCE, WaterHeaterEntityFeature, ) -from homeassistant.const import ATTR_TEMPERATURE, STATE_OFF, Platform, UnitOfTemperature +from homeassistant.const import ATTR_TEMPERATURE, STATE_OFF, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.util.unit_conversion import TemperatureConverter @@ -96,13 +96,6 @@ DEFAULT_CONFIG = { } -@pytest.fixture(autouse=True) -def water_heater_platform_only(): - """Only setup the water heater platform to speed up tests.""" - with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.WATER_HEATER]): - yield - - @pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) async def test_setup_params( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator diff --git a/tests/conftest.py b/tests/conftest.py index 798e3980f7b..40bd4157957 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -935,8 +935,7 @@ async def mqtt_mock( mqtt_mock_entry: MqttMockHAClientGenerator, ) -> AsyncGenerator[MqttMockHAClient, None]: """Fixture to mock MQTT component.""" - with patch("homeassistant.components.mqtt.PLATFORMS", []): - return await mqtt_mock_entry() + return await mqtt_mock_entry() @asynccontextmanager