1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-25 19:29:04 +01:00

Use mock_platform for event entity component tests instead of hass.components (#113667)

This commit is contained in:
Jan-Philipp Benecke
2024-03-17 17:32:16 +01:00
committed by GitHub
parent 75a489deb9
commit 25c4ab070b
4 changed files with 61 additions and 61 deletions

View File

@@ -1,43 +0,0 @@
"""Provide a mock event platform.
Call init before using it in your tests to ensure clean test data.
"""
from homeassistant.components.event import EventEntity
from tests.common import MockEntity
ENTITIES = []
class MockEventEntity(MockEntity, EventEntity):
"""Mock EventEntity class."""
@property
def event_types(self) -> list[str]:
"""Return a list of possible events."""
return self._handle("event_types")
def init(empty=False):
"""Initialize the platform with entities."""
global ENTITIES
ENTITIES = (
[]
if empty
else [
MockEventEntity(
name="doorbell",
unique_id="unique_doorbell",
event_types=["short_press", "long_press"],
),
]
)
async def async_setup_platform(
hass, config, async_add_entities_callback, discovery_info=None
):
"""Return mock entities."""
async_add_entities_callback(ENTITIES)