mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 10:59:40 +00:00
Speed up mqtt tests (#73423)
Co-authored-by: jbouwh <jan@jbsoft.nl> Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
This commit is contained in:
@@ -22,6 +22,7 @@ from homeassistant.const import (
|
||||
EVENT_HOMEASSISTANT_STARTED,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
TEMP_CELSIUS,
|
||||
Platform,
|
||||
)
|
||||
import homeassistant.core as ha
|
||||
from homeassistant.core import CoreState, HomeAssistant, callback
|
||||
@@ -51,6 +52,16 @@ class RecordCallsPartial(partial):
|
||||
__name__ = "RecordCallPartialTest"
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def sensor_platforms_only():
|
||||
"""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):
|
||||
"""Autouse hass_storage for the TestCase tests."""
|
||||
@@ -1362,6 +1373,7 @@ async def test_setup_override_configuration(hass, caplog, tmp_path):
|
||||
assert calls_username_password_set[0][1] == "somepassword"
|
||||
|
||||
|
||||
@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.LIGHT])
|
||||
async def test_setup_manual_mqtt_with_platform_key(hass, caplog):
|
||||
"""Test set up a manual MQTT item with a platform key."""
|
||||
config = {"platform": "mqtt", "name": "test", "command_topic": "test-topic"}
|
||||
@@ -1372,6 +1384,7 @@ async def test_setup_manual_mqtt_with_platform_key(hass, caplog):
|
||||
)
|
||||
|
||||
|
||||
@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.LIGHT])
|
||||
async def test_setup_manual_mqtt_with_invalid_config(hass, caplog):
|
||||
"""Test set up a manual MQTT item with an invalid config."""
|
||||
config = {"name": "test"}
|
||||
@@ -2013,6 +2026,7 @@ 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, device_reg, hass_ws_client, mqtt_mock_entry_no_yaml_config
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user