mirror of
https://github.com/home-assistant/core.git
synced 2025-12-26 14:08:21 +00:00
Use config entry to setup platforms (#13752)
* Use config entry to setup platforms * Rename to async_forward_entry * Add tests * Catch if platform not exists for entry
This commit is contained in:
@@ -344,7 +344,8 @@ class MockPlatform(object):
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
def __init__(self, setup_platform=None, dependencies=None,
|
||||
platform_schema=None, async_setup_platform=None):
|
||||
platform_schema=None, async_setup_platform=None,
|
||||
async_setup_entry=None):
|
||||
"""Initialize the platform."""
|
||||
self.DEPENDENCIES = dependencies or []
|
||||
|
||||
@@ -358,6 +359,9 @@ class MockPlatform(object):
|
||||
if async_setup_platform is not None:
|
||||
self.async_setup_platform = async_setup_platform
|
||||
|
||||
if async_setup_entry is not None:
|
||||
self.async_setup_entry = async_setup_entry
|
||||
|
||||
if setup_platform is None and async_setup_platform is None:
|
||||
self.async_setup_platform = mock_coro_func()
|
||||
|
||||
@@ -376,6 +380,14 @@ class MockEntityPlatform(entity_platform.EntityPlatform):
|
||||
async_entities_added_callback=lambda: None
|
||||
):
|
||||
"""Initialize a mock entity platform."""
|
||||
if logger is None:
|
||||
logger = logging.getLogger('homeassistant.helpers.entity_platform')
|
||||
|
||||
# Otherwise the constructor will blow up.
|
||||
if (isinstance(platform, Mock) and
|
||||
isinstance(platform.PARALLEL_UPDATES, Mock)):
|
||||
platform.PARALLEL_UPDATES = 0
|
||||
|
||||
super().__init__(
|
||||
hass=hass,
|
||||
logger=logger,
|
||||
|
||||
Reference in New Issue
Block a user