Expose all components on hass [Concept] (#8490)
* Add components concept * Lint * Raise ImportError if component not found
This commit is contained in:
parent
bffa0d2b04
commit
d3be056d15
4 changed files with 79 additions and 1 deletions
|
@ -1,11 +1,15 @@
|
|||
"""Test to verify that we can load components."""
|
||||
# pylint: disable=protected-access
|
||||
import asyncio
|
||||
import unittest
|
||||
|
||||
import pytest
|
||||
|
||||
import homeassistant.loader as loader
|
||||
import homeassistant.components.http as http
|
||||
|
||||
from tests.common import get_test_home_assistant, MockModule
|
||||
from tests.common import (
|
||||
get_test_home_assistant, MockModule, async_mock_service)
|
||||
|
||||
|
||||
class TestLoader(unittest.TestCase):
|
||||
|
@ -54,3 +58,29 @@ class TestLoader(unittest.TestCase):
|
|||
|
||||
# Try to get load order for non-existing component
|
||||
self.assertEqual([], loader.load_order_component('mod1'))
|
||||
|
||||
|
||||
def test_component_loader(hass):
|
||||
"""Test loading components."""
|
||||
components = loader.Components(hass)
|
||||
assert components.http.CONFIG_SCHEMA is http.CONFIG_SCHEMA
|
||||
assert hass.components.http.CONFIG_SCHEMA is http.CONFIG_SCHEMA
|
||||
|
||||
|
||||
def test_component_loader_non_existing(hass):
|
||||
"""Test loading components."""
|
||||
components = loader.Components(hass)
|
||||
with pytest.raises(ImportError):
|
||||
components.non_existing
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_component_wrapper(hass):
|
||||
"""Test component wrapper."""
|
||||
calls = async_mock_service(hass, 'light', 'turn_on')
|
||||
|
||||
components = loader.Components(hass)
|
||||
components.light.async_turn_on('light.test')
|
||||
yield from hass.async_block_till_done()
|
||||
|
||||
assert len(calls) == 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue