Update platform loading path (#20807)

* Warn when platform loaded from an entity component folder

* Fix tests
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2019-02-07 13:33:12 -08:00
1 parent e0f63132e8
commit 16159cc3d0
5 files changed
+33 -9

No files matched your search

+2
View File
@@ -486,6 +486,8 @@ class MockModule:
class MockPlatform:
"""Provide a fake platform."""
__name__ = "homeassistant.components.light.bla"
# pylint: disable=invalid-name
def __init__(self, setup_platform=None, dependencies=None,
platform_schema=None, async_setup_platform=None,
+14
View File
@@ -132,3 +132,17 @@ async def test_log_warning_custom_component(hass, caplog):
loader.get_component(hass, 'light.test')
assert 'You are using a custom component for light.test' in caplog.text
async def test_get_platform(hass, caplog):
"""Test get_platform."""
# Test we prefer embedded over normal platforms."""
embedded_platform = loader.get_platform(hass, 'switch', 'test_embedded')
assert embedded_platform.__name__ == \
'custom_components.test_embedded.switch'
caplog.clear()
legacy_platform = loader.get_platform(hass, 'switch', 'test')
assert legacy_platform.__name__ == 'custom_components.switch.test'
assert 'Integrations need to be in their own folder.' in caplog.text
@@ -0,0 +1 @@
"""Test switch platform for test_embedded component."""