mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Loader test tests now custom component loading
This commit is contained in:
parent
9c4111403e
commit
c3047efc45
3
test/config/custom_components/custom_one.py
Normal file
3
test/config/custom_components/custom_one.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
"""
|
||||||
|
Module to be loaded by the Loader test.
|
||||||
|
"""
|
@ -4,9 +4,24 @@ test.helper
|
|||||||
|
|
||||||
Helper method for writing tests.
|
Helper method for writing tests.
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
|
|
||||||
|
import homeassistant as ha
|
||||||
|
|
||||||
|
|
||||||
|
def get_test_home_assistant():
|
||||||
|
""" Returns a Home Assistant object pointing at test config dir. """
|
||||||
|
hass = ha.HomeAssistant()
|
||||||
|
hass.config_dir = os.path.join(os.path.dirname(__file__), "config")
|
||||||
|
|
||||||
|
return hass
|
||||||
|
|
||||||
|
|
||||||
def mock_service(hass, domain, service):
|
def mock_service(hass, domain, service):
|
||||||
|
"""
|
||||||
|
Sets up a fake service.
|
||||||
|
Returns a list that logs all calls to fake service.
|
||||||
|
"""
|
||||||
calls = []
|
calls = []
|
||||||
|
|
||||||
hass.services.register(
|
hass.services.register(
|
||||||
|
@ -12,12 +12,13 @@ import homeassistant.loader as loader
|
|||||||
import homeassistant.components.http as http
|
import homeassistant.components.http as http
|
||||||
|
|
||||||
import mock_toggledevice_platform
|
import mock_toggledevice_platform
|
||||||
|
from helper import get_test_home_assistant
|
||||||
|
|
||||||
|
|
||||||
class TestLoader(unittest.TestCase):
|
class TestLoader(unittest.TestCase):
|
||||||
""" Test the loader module. """
|
""" Test the loader module. """
|
||||||
def setUp(self): # pylint: disable=invalid-name
|
def setUp(self): # pylint: disable=invalid-name
|
||||||
self.hass = ha.HomeAssistant()
|
self.hass = get_test_home_assistant()
|
||||||
loader.prepare(self.hass)
|
loader.prepare(self.hass)
|
||||||
|
|
||||||
def tearDown(self): # pylint: disable=invalid-name
|
def tearDown(self): # pylint: disable=invalid-name
|
||||||
@ -34,3 +35,5 @@ class TestLoader(unittest.TestCase):
|
|||||||
def test_get_component(self):
|
def test_get_component(self):
|
||||||
""" Test if get_component works. """
|
""" Test if get_component works. """
|
||||||
self.assertEqual(http, loader.get_component('http'))
|
self.assertEqual(http, loader.get_component('http'))
|
||||||
|
|
||||||
|
self.assertIsNotNone(loader.get_component('custom_one'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user