mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Update roborock tests to only load the platform under test (#134694)
This commit is contained in:
parent
901099325b
commit
a66cf62b09
@ -1,5 +1,6 @@
|
||||
"""Global fixtures for Roborock integration."""
|
||||
|
||||
from collections.abc import Generator
|
||||
from copy import deepcopy
|
||||
from unittest.mock import patch
|
||||
|
||||
@ -14,7 +15,7 @@ from homeassistant.components.roborock.const import (
|
||||
CONF_USER_DATA,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.const import CONF_USERNAME
|
||||
from homeassistant.const import CONF_USERNAME, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
@ -167,13 +168,21 @@ def mock_roborock_entry(hass: HomeAssistant) -> MockConfigEntry:
|
||||
return mock_entry
|
||||
|
||||
|
||||
@pytest.fixture(name="platforms")
|
||||
def mock_platforms() -> list[Platform]:
|
||||
"""Fixture to specify platforms to test."""
|
||||
return []
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def setup_entry(
|
||||
hass: HomeAssistant,
|
||||
bypass_api_fixture,
|
||||
mock_roborock_entry: MockConfigEntry,
|
||||
) -> MockConfigEntry:
|
||||
platforms: list[Platform],
|
||||
) -> Generator[MockConfigEntry]:
|
||||
"""Set up the Roborock platform."""
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
await hass.async_block_till_done()
|
||||
return mock_roborock_entry
|
||||
with patch("homeassistant.components.roborock.PLATFORMS", platforms):
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
await hass.async_block_till_done()
|
||||
yield mock_roborock_entry
|
||||
|
@ -1,10 +1,19 @@
|
||||
"""Test Roborock Binary Sensor."""
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def platforms() -> list[Platform]:
|
||||
"""Fixture to set platforms used in the test."""
|
||||
return [Platform.BINARY_SENSOR]
|
||||
|
||||
|
||||
async def test_binary_sensors(
|
||||
hass: HomeAssistant, setup_entry: MockConfigEntry
|
||||
) -> None:
|
||||
|
@ -6,12 +6,19 @@ import pytest
|
||||
import roborock
|
||||
|
||||
from homeassistant.components.button import SERVICE_PRESS
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def platforms() -> list[Platform]:
|
||||
"""Fixture to set platforms used in the test."""
|
||||
return [Platform.BUTTON]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("entity_id"),
|
||||
[
|
||||
|
@ -5,10 +5,11 @@ from datetime import timedelta
|
||||
from http import HTTPStatus
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from roborock import RoborockException
|
||||
|
||||
from homeassistant.components.roborock import DOMAIN
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
from homeassistant.const import STATE_UNAVAILABLE, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import dt as dt_util
|
||||
@ -19,6 +20,12 @@ from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def platforms() -> list[Platform]:
|
||||
"""Fixture to set platforms used in the test."""
|
||||
return [Platform.IMAGE]
|
||||
|
||||
|
||||
async def test_floorplan_image(
|
||||
hass: HomeAssistant,
|
||||
setup_entry: MockConfigEntry,
|
||||
|
@ -6,12 +6,19 @@ import pytest
|
||||
import roborock
|
||||
|
||||
from homeassistant.components.number import ATTR_VALUE, SERVICE_SET_VALUE
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def platforms() -> list[Platform]:
|
||||
"""Fixture to set platforms used in the test."""
|
||||
return [Platform.NUMBER]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("entity_id", "value"),
|
||||
[
|
||||
|
@ -7,7 +7,7 @@ import pytest
|
||||
from roborock.exceptions import RoborockException
|
||||
|
||||
from homeassistant.components.roborock import DOMAIN
|
||||
from homeassistant.const import SERVICE_SELECT_OPTION, STATE_UNKNOWN
|
||||
from homeassistant.const import SERVICE_SELECT_OPTION, STATE_UNKNOWN, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.setup import async_setup_component
|
||||
@ -17,6 +17,12 @@ from .mock_data import MULTI_MAP_LIST, PROP
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def platforms() -> list[Platform]:
|
||||
"""Fixture to set platforms used in the test."""
|
||||
return [Platform.SELECT]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("entity_id", "value"),
|
||||
[
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from roborock import DeviceData, HomeDataDevice
|
||||
from roborock.const import (
|
||||
FILTER_REPLACE_TIME,
|
||||
@ -12,6 +13,7 @@ from roborock.const import (
|
||||
from roborock.roborock_message import RoborockMessage, RoborockMessageProtocol
|
||||
from roborock.version_1_apis import RoborockMqttClientV1
|
||||
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .mock_data import CONSUMABLE, STATUS, USER_DATA
|
||||
@ -19,6 +21,12 @@ from .mock_data import CONSUMABLE, STATUS, USER_DATA
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def platforms() -> list[Platform]:
|
||||
"""Fixture to set platforms used in the test."""
|
||||
return [Platform.SENSOR]
|
||||
|
||||
|
||||
async def test_sensors(hass: HomeAssistant, setup_entry: MockConfigEntry) -> None:
|
||||
"""Test sensors and check test values are correctly set."""
|
||||
assert len(hass.states.async_all("sensor")) == 38
|
||||
|
@ -6,12 +6,19 @@ import pytest
|
||||
import roborock
|
||||
|
||||
from homeassistant.components.switch import SERVICE_TURN_OFF, SERVICE_TURN_ON
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def platforms() -> list[Platform]:
|
||||
"""Fixture to set platforms used in the test."""
|
||||
return [Platform.SWITCH]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("entity_id"),
|
||||
[
|
||||
|
@ -7,12 +7,19 @@ import pytest
|
||||
import roborock
|
||||
|
||||
from homeassistant.components.time import SERVICE_SET_VALUE
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def platforms() -> list[Platform]:
|
||||
"""Fixture to set platforms used in the test."""
|
||||
return [Platform.TIME]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("entity_id"),
|
||||
[
|
||||
|
@ -40,6 +40,15 @@ ENTITY_ID = "vacuum.roborock_s7_maxv"
|
||||
DEVICE_ID = "abc123"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def platforms() -> list[Platform]:
|
||||
"""Fixture to set platforms used in the test."""
|
||||
# Note: Currently the Image platform is required to make these tests pass since
|
||||
# some initialization of the coordinator happens as a side effect of loading
|
||||
# image platform. Fix that and remove IMAGE here.
|
||||
return [Platform.VACUUM, Platform.IMAGE]
|
||||
|
||||
|
||||
async def test_registry_entries(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
|
Loading…
x
Reference in New Issue
Block a user