1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Allow renaming entities in entity registry (#12636)

* Allow renaming entities in entity registry

* Lint
This commit is contained in:
Paulus Schoutsen
2018-02-24 10:53:59 -08:00
committed by GitHub
parent 2821820281
commit 6d431c3fc3
9 changed files with 333 additions and 47 deletions

View File

@@ -1,5 +1,6 @@
"""Test the helper method for writing tests."""
import asyncio
from datetime import timedelta
import functools as ft
import os
import sys
@@ -298,7 +299,7 @@ def mock_registry(hass, mock_entries=None):
"""Mock the Entity Registry."""
registry = entity_registry.EntityRegistry(hass)
registry.entities = mock_entries or {}
hass.data[entity_platform.DATA_REGISTRY] = registry
hass.data[entity_registry.DATA_REGISTRY] = registry
return registry
@@ -361,6 +362,32 @@ class MockPlatform(object):
self.async_setup_platform = mock_coro_func()
class MockEntityPlatform(entity_platform.EntityPlatform):
"""Mock class with some mock defaults."""
def __init__(
self, hass,
logger=None,
domain='test_domain',
platform_name='test_platform',
scan_interval=timedelta(seconds=15),
parallel_updates=0,
entity_namespace=None,
async_entities_added_callback=lambda: None
):
"""Initialize a mock entity platform."""
super().__init__(
hass=hass,
logger=logger,
domain=domain,
platform_name=platform_name,
scan_interval=scan_interval,
parallel_updates=parallel_updates,
entity_namespace=entity_namespace,
async_entities_added_callback=async_entities_added_callback,
)
class MockToggleDevice(entity.ToggleEntity):
"""Provide a mock toggle device."""