mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
committed by
Jason Hu
parent
23cb579f9f
commit
b0d893afc9
@@ -8,11 +8,6 @@ from homeassistant.components.hue import light as hue_light
|
||||
from tests.common import MockModule, async_mock_service, mock_integration
|
||||
|
||||
|
||||
def test_get_component(hass):
|
||||
"""Test if get_component works."""
|
||||
assert http == loader.get_component(hass, 'http')
|
||||
|
||||
|
||||
async def test_component_dependencies(hass):
|
||||
"""Test if we can get the proper load order of components."""
|
||||
mock_integration(hass, MockModule('mod1'))
|
||||
@@ -84,17 +79,28 @@ async def test_helpers_wrapper(hass):
|
||||
|
||||
async def test_custom_component_name(hass):
|
||||
"""Test the name attribte of custom components."""
|
||||
comp = loader.get_component(hass, 'test_standalone')
|
||||
integration = await loader.async_get_integration(hass, 'test_standalone')
|
||||
int_comp = integration.get_component()
|
||||
assert int_comp.__name__ == 'custom_components.test_standalone'
|
||||
assert int_comp.__package__ == 'custom_components'
|
||||
|
||||
comp = hass.components.test_standalone
|
||||
assert comp.__name__ == 'custom_components.test_standalone'
|
||||
assert comp.__package__ == 'custom_components'
|
||||
|
||||
comp = loader.get_component(hass, 'test_package')
|
||||
integration = await loader.async_get_integration(hass, 'test_package')
|
||||
int_comp = integration.get_component()
|
||||
assert int_comp.__name__ == 'custom_components.test_package'
|
||||
assert int_comp.__package__ == 'custom_components.test_package'
|
||||
|
||||
comp = hass.components.test_package
|
||||
assert comp.__name__ == 'custom_components.test_package'
|
||||
assert comp.__package__ == 'custom_components.test_package'
|
||||
|
||||
comp = loader.get_component(hass, 'test.light')
|
||||
assert comp.__name__ == 'custom_components.test.light'
|
||||
assert comp.__package__ == 'custom_components.test'
|
||||
integration = await loader.async_get_integration(hass, 'test')
|
||||
platform = integration.get_platform('light')
|
||||
assert platform.__name__ == 'custom_components.test.light'
|
||||
assert platform.__package__ == 'custom_components.test'
|
||||
|
||||
# Test custom components is mounted
|
||||
from custom_components.test_package import TEST
|
||||
@@ -103,12 +109,12 @@ async def test_custom_component_name(hass):
|
||||
|
||||
async def test_log_warning_custom_component(hass, caplog):
|
||||
"""Test that we log a warning when loading a custom component."""
|
||||
loader.get_component(hass, 'test_standalone')
|
||||
assert \
|
||||
'You are using a custom component for test_standalone' in caplog.text
|
||||
hass.components.test_standalone
|
||||
assert 'You are using a custom integration for test_standalone' \
|
||||
in caplog.text
|
||||
|
||||
loader.get_component(hass, 'test.light')
|
||||
assert 'You are using a custom component for test.light' in caplog.text
|
||||
await loader.async_get_integration(hass, 'test')
|
||||
assert 'You are using a custom integration for test ' in caplog.text
|
||||
|
||||
|
||||
async def test_get_integration(hass):
|
||||
|
||||
Reference in New Issue
Block a user