From 04b68902e3b63b942bf7b9399c69eada92c00f73 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 11 Feb 2018 23:26:52 -0800 Subject: [PATCH] Fix platform dependencies (#12330) --- homeassistant/setup.py | 2 +- tests/helpers/test_entity_component.py | 30 +++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/homeassistant/setup.py b/homeassistant/setup.py index 364bbc94230..2c69fdefeee 100644 --- a/homeassistant/setup.py +++ b/homeassistant/setup.py @@ -206,7 +206,7 @@ def async_prepare_setup_platform(hass: core.HomeAssistant, config, domain: str, return platform try: - yield from _process_deps_reqs(hass, config, platform_name, platform) + yield from _process_deps_reqs(hass, config, platform_path, platform) except HomeAssistantError as err: log_error(str(err)) return None diff --git a/tests/helpers/test_entity_component.py b/tests/helpers/test_entity_component.py index ef92da3172b..d8dac11f6a0 100644 --- a/tests/helpers/test_entity_component.py +++ b/tests/helpers/test_entity_component.py @@ -12,7 +12,7 @@ import homeassistant.loader as loader from homeassistant.exceptions import PlatformNotReady from homeassistant.components import group from homeassistant.helpers.entity_component import EntityComponent -from homeassistant.setup import setup_component +from homeassistant.setup import setup_component, async_setup_component from homeassistant.helpers import discovery import homeassistant.util.dt as dt_util @@ -305,3 +305,31 @@ def test_extract_from_service_no_group_expand(hass): extracted = component.async_extract_from_service(call, expand_group=False) assert extracted == [test_group] + + +@asyncio.coroutine +def test_setup_dependencies_platform(hass): + """Test we setup the dependencies of a platform. + + We're explictely testing that we process dependencies even if a component + with the same name has already been loaded. + """ + loader.set_component('test_component', MockModule('test_component')) + loader.set_component('test_component2', MockModule('test_component2')) + loader.set_component( + 'test_domain.test_component', + MockPlatform(dependencies=['test_component', 'test_component2'])) + + component = EntityComponent(_LOGGER, DOMAIN, hass) + + yield from async_setup_component(hass, 'test_component', {}) + + yield from component.async_setup({ + DOMAIN: { + 'platform': 'test_component', + } + }) + + assert 'test_component' in hass.config.components + assert 'test_component2' in hass.config.components + assert 'test_domain.test_component' in hass.config.components