Loader test tests now custom component loading
This commit is contained in:
parent
9c4111403e
commit
c3047efc45
3 changed files with 22 additions and 1 deletions
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.
|
||||
"""
|
||||
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):
|
||||
"""
|
||||
Sets up a fake service.
|
||||
Returns a list that logs all calls to fake service.
|
||||
"""
|
||||
calls = []
|
||||
|
||||
hass.services.register(
|
||||
|
|
|
@ -12,12 +12,13 @@ import homeassistant.loader as loader
|
|||
import homeassistant.components.http as http
|
||||
|
||||
import mock_toggledevice_platform
|
||||
from helper import get_test_home_assistant
|
||||
|
||||
|
||||
class TestLoader(unittest.TestCase):
|
||||
""" Test the loader module. """
|
||||
def setUp(self): # pylint: disable=invalid-name
|
||||
self.hass = ha.HomeAssistant()
|
||||
self.hass = get_test_home_assistant()
|
||||
loader.prepare(self.hass)
|
||||
|
||||
def tearDown(self): # pylint: disable=invalid-name
|
||||
|
@ -34,3 +35,5 @@ class TestLoader(unittest.TestCase):
|
|||
def test_get_component(self):
|
||||
""" Test if get_component works. """
|
||||
self.assertEqual(http, loader.get_component('http'))
|
||||
|
||||
self.assertIsNotNone(loader.get_component('custom_one'))
|
||||
|
|
Loading…
Add table
Reference in a new issue