Use setup_component in tests (#3414)

* Alarm Control Panel Manual - use setup_component

* Update automation - zone tests

* Update climate - demo tests

* Update climate - generic thermostat tests

* Update cover - command line tests

* Update cover - demo tests

* Update device tracker tests

* Update device tracker - owntracks tests

* Update fan - demo tests

* Update garage door - demo tests

* Update light tests

* Update lock - demo tests

* Update media player - demo tests

* Update notify - command line tests

* Update notify - demo tests

* Update notify - file tests

* Update notify - group tests

* Update sensor - mfi tests

* Update sensor - moldindicator tests

* Update sensor - mqtt room tests

* Update switch - command line

* Update switch - flux

* Update switch tests

* Update scene tests

* Fix wrong default port for mfi switch
This commit is contained in:
Paulus Schoutsen 2016-09-17 10:29:58 -07:00 committed by GitHub
parent d7452f9d5d
commit 4076ccf639
29 changed files with 220 additions and 141 deletions

View file

@ -28,7 +28,7 @@ PLATFORM_SCHEMA = vol.Schema({
vol.Optional(CONF_NAME, default=DEFAULT_ALARM_NAME): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_ALARM_NAME): cv.string,
vol.Optional(CONF_CODE): cv.string, vol.Optional(CONF_CODE): cv.string,
vol.Optional(CONF_PENDING_TIME, default=DEFAULT_PENDING_TIME): vol.Optional(CONF_PENDING_TIME, default=DEFAULT_PENDING_TIME):
vol.All(vol.Coerce(int), vol.Range(min=1)), vol.All(vol.Coerce(int), vol.Range(min=0)),
vol.Optional(CONF_TRIGGER_TIME, default=DEFAULT_TRIGGER_TIME): vol.Optional(CONF_TRIGGER_TIME, default=DEFAULT_TRIGGER_TIME):
vol.All(vol.Coerce(int), vol.Range(min=1)), vol.All(vol.Coerce(int), vol.Range(min=1)),
vol.Optional(CONF_DISARM_AFTER_TRIGGER, vol.Optional(CONF_DISARM_AFTER_TRIGGER,

@ -1 +1 @@
Subproject commit ba588fc779d34a2fbf7cc9a23103c38e3e3e0356 Subproject commit bd6725d58d4493651a02184778d9f5d0a611698c

View file

@ -20,7 +20,6 @@ REQUIREMENTS = ['mficlient==0.3.0']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
DEFAULT_PORT = 6443
DEFAULT_SSL = True DEFAULT_SSL = True
DEFAULT_VERIFY_SSL = True DEFAULT_VERIFY_SSL = True
@ -43,7 +42,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_HOST): cv.string, vol.Required(CONF_HOST): cv.string,
vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string, vol.Required(CONF_PASSWORD): cv.string,
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port, vol.Optional(CONF_PORT): cv.port,
vol.Optional(CONF_SSL, default=DEFAULT_SSL): cv.boolean, vol.Optional(CONF_SSL, default=DEFAULT_SSL): cv.boolean,
vol.Optional(CONF_VERIFY_SSL, default=DEFAULT_VERIFY_SSL): cv.boolean, vol.Optional(CONF_VERIFY_SSL, default=DEFAULT_VERIFY_SSL): cv.boolean,
}) })
@ -57,7 +56,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
password = config.get(CONF_PASSWORD) password = config.get(CONF_PASSWORD)
use_tls = config.get(CONF_SSL) use_tls = config.get(CONF_SSL)
verify_tls = config.get(CONF_VERIFY_SSL) verify_tls = config.get(CONF_VERIFY_SSL)
default_port = use_tls and DEFAULT_PORT or 6080 default_port = use_tls and 6443 or 6080
port = int(config.get(CONF_PORT, default_port)) port = int(config.get(CONF_PORT, default_port))
from mficlient.client import FailedToLogin, MFiClient from mficlient.client import FailedToLogin, MFiClient

View file

@ -19,7 +19,6 @@ REQUIREMENTS = ['mficlient==0.3.0']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
DEFAULT_PORT = 6443
DEFAULT_SSL = True DEFAULT_SSL = True
DEFAULT_VERIFY_SSL = True DEFAULT_VERIFY_SSL = True
@ -34,7 +33,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_HOST): cv.string, vol.Required(CONF_HOST): cv.string,
vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string, vol.Required(CONF_PASSWORD): cv.string,
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port, vol.Optional(CONF_PORT): cv.port,
vol.Optional(CONF_SSL, default=DEFAULT_SSL): cv.boolean, vol.Optional(CONF_SSL, default=DEFAULT_SSL): cv.boolean,
vol.Optional(CONF_VERIFY_SSL, default=DEFAULT_VERIFY_SSL): cv.boolean, vol.Optional(CONF_VERIFY_SSL, default=DEFAULT_VERIFY_SSL): cv.boolean,
}) })
@ -48,7 +47,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
password = config.get(CONF_PASSWORD) password = config.get(CONF_PASSWORD)
use_tls = config.get(CONF_SSL) use_tls = config.get(CONF_SSL)
verify_tls = config.get(CONF_VERIFY_SSL) verify_tls = config.get(CONF_VERIFY_SSL)
default_port = use_tls and DEFAULT_PORT or 6080 default_port = use_tls and 6443 or 6080
port = int(config.get(CONF_PORT, default_port)) port = int(config.get(CONF_PORT, default_port))
from mficlient.client import FailedToLogin, MFiClient from mficlient.client import FailedToLogin, MFiClient

View file

@ -42,6 +42,7 @@ def get_test_home_assistant(num_threads=None):
if num_threads: if num_threads:
ha.MIN_WORKER_THREAD = orig_num_threads ha.MIN_WORKER_THREAD = orig_num_threads
hass.config.location_name = 'test home'
hass.config.config_dir = get_test_config_dir() hass.config.config_dir = get_test_config_dir()
hass.config.latitude = 32.87336 hass.config.latitude = 32.87336
hass.config.longitude = -117.22743 hass.config.longitude = -117.22743

View file

@ -3,6 +3,7 @@ from datetime import timedelta
import unittest import unittest
from unittest.mock import patch from unittest.mock import patch
from homeassistant.bootstrap import setup_component
from homeassistant.const import ( from homeassistant.const import (
STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY, STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY,
STATE_ALARM_PENDING, STATE_ALARM_TRIGGERED) STATE_ALARM_PENDING, STATE_ALARM_TRIGGERED)
@ -27,8 +28,9 @@ class TestAlarmControlPanelManual(unittest.TestCase):
def test_arm_home_no_pending(self): def test_arm_home_no_pending(self):
"""Test arm home method.""" """Test arm home method."""
self.assertTrue(alarm_control_panel.setup(self.hass, { self.assertTrue(setup_component(
'alarm_control_panel': { self.hass, alarm_control_panel.DOMAIN,
{'alarm_control_panel': {
'platform': 'manual', 'platform': 'manual',
'name': 'test', 'name': 'test',
'code': CODE, 'code': CODE,
@ -49,8 +51,9 @@ class TestAlarmControlPanelManual(unittest.TestCase):
def test_arm_home_with_pending(self): def test_arm_home_with_pending(self):
"""Test arm home method.""" """Test arm home method."""
self.assertTrue(alarm_control_panel.setup(self.hass, { self.assertTrue(setup_component(
'alarm_control_panel': { self.hass, alarm_control_panel.DOMAIN,
{'alarm_control_panel': {
'platform': 'manual', 'platform': 'manual',
'name': 'test', 'name': 'test',
'code': CODE, 'code': CODE,
@ -80,8 +83,9 @@ class TestAlarmControlPanelManual(unittest.TestCase):
def test_arm_home_with_invalid_code(self): def test_arm_home_with_invalid_code(self):
"""Attempt to arm home without a valid code.""" """Attempt to arm home without a valid code."""
self.assertTrue(alarm_control_panel.setup(self.hass, { self.assertTrue(setup_component(
'alarm_control_panel': { self.hass, alarm_control_panel.DOMAIN,
{'alarm_control_panel': {
'platform': 'manual', 'platform': 'manual',
'name': 'test', 'name': 'test',
'code': CODE, 'code': CODE,
@ -102,8 +106,9 @@ class TestAlarmControlPanelManual(unittest.TestCase):
def test_arm_away_no_pending(self): def test_arm_away_no_pending(self):
"""Test arm home method.""" """Test arm home method."""
self.assertTrue(alarm_control_panel.setup(self.hass, { self.assertTrue(setup_component(
'alarm_control_panel': { self.hass, alarm_control_panel.DOMAIN,
{'alarm_control_panel': {
'platform': 'manual', 'platform': 'manual',
'name': 'test', 'name': 'test',
'code': CODE, 'code': CODE,
@ -124,8 +129,9 @@ class TestAlarmControlPanelManual(unittest.TestCase):
def test_arm_away_with_pending(self): def test_arm_away_with_pending(self):
"""Test arm home method.""" """Test arm home method."""
self.assertTrue(alarm_control_panel.setup(self.hass, { self.assertTrue(setup_component(
'alarm_control_panel': { self.hass, alarm_control_panel.DOMAIN,
{'alarm_control_panel': {
'platform': 'manual', 'platform': 'manual',
'name': 'test', 'name': 'test',
'code': CODE, 'code': CODE,
@ -155,8 +161,9 @@ class TestAlarmControlPanelManual(unittest.TestCase):
def test_arm_away_with_invalid_code(self): def test_arm_away_with_invalid_code(self):
"""Attempt to arm away without a valid code.""" """Attempt to arm away without a valid code."""
self.assertTrue(alarm_control_panel.setup(self.hass, { self.assertTrue(setup_component(
'alarm_control_panel': { self.hass, alarm_control_panel.DOMAIN,
{'alarm_control_panel': {
'platform': 'manual', 'platform': 'manual',
'name': 'test', 'name': 'test',
'code': CODE, 'code': CODE,
@ -176,12 +183,13 @@ class TestAlarmControlPanelManual(unittest.TestCase):
self.hass.states.get(entity_id).state) self.hass.states.get(entity_id).state)
def test_trigger_no_pending(self): def test_trigger_no_pending(self):
"""Test arm home method.""" """Test triggering when no pending submitted method."""
self.assertTrue(alarm_control_panel.setup(self.hass, { self.assertTrue(setup_component(
'alarm_control_panel': { self.hass, alarm_control_panel.DOMAIN,
{'alarm_control_panel': {
'platform': 'manual', 'platform': 'manual',
'name': 'test', 'name': 'test',
'trigger_time': 0, 'trigger_time': 1,
'disarm_after_trigger': False 'disarm_after_trigger': False
}})) }}))
@ -193,13 +201,23 @@ class TestAlarmControlPanelManual(unittest.TestCase):
alarm_control_panel.alarm_trigger(self.hass, entity_id=entity_id) alarm_control_panel.alarm_trigger(self.hass, entity_id=entity_id)
self.hass.block_till_done() self.hass.block_till_done()
self.assertEqual(STATE_ALARM_PENDING,
self.hass.states.get(entity_id).state)
future = dt_util.utcnow() + timedelta(seconds=60)
with patch(('homeassistant.components.alarm_control_panel.manual.'
'dt_util.utcnow'), return_value=future):
fire_time_changed(self.hass, future)
self.hass.block_till_done()
self.assertEqual(STATE_ALARM_TRIGGERED, self.assertEqual(STATE_ALARM_TRIGGERED,
self.hass.states.get(entity_id).state) self.hass.states.get(entity_id).state)
def test_trigger_with_pending(self): def test_trigger_with_pending(self):
"""Test arm home method.""" """Test arm home method."""
self.assertTrue(alarm_control_panel.setup(self.hass, { self.assertTrue(setup_component(
'alarm_control_panel': { self.hass, alarm_control_panel.DOMAIN,
{'alarm_control_panel': {
'platform': 'manual', 'platform': 'manual',
'name': 'test', 'name': 'test',
'pending_time': 2, 'pending_time': 2,
@ -238,8 +256,9 @@ class TestAlarmControlPanelManual(unittest.TestCase):
def test_trigger_with_disarm_after_trigger(self): def test_trigger_with_disarm_after_trigger(self):
"""Test disarm after trigger.""" """Test disarm after trigger."""
self.assertTrue(alarm_control_panel.setup(self.hass, { self.assertTrue(setup_component(
'alarm_control_panel': { self.hass, alarm_control_panel.DOMAIN,
{'alarm_control_panel': {
'platform': 'manual', 'platform': 'manual',
'name': 'test', 'name': 'test',
'trigger_time': 5, 'trigger_time': 5,
@ -269,8 +288,9 @@ class TestAlarmControlPanelManual(unittest.TestCase):
def test_disarm_while_pending_trigger(self): def test_disarm_while_pending_trigger(self):
"""Test disarming while pending state.""" """Test disarming while pending state."""
self.assertTrue(alarm_control_panel.setup(self.hass, { self.assertTrue(setup_component(
'alarm_control_panel': { self.hass, alarm_control_panel.DOMAIN,
{'alarm_control_panel': {
'platform': 'manual', 'platform': 'manual',
'name': 'test', 'name': 'test',
'trigger_time': 5, 'trigger_time': 5,
@ -305,8 +325,9 @@ class TestAlarmControlPanelManual(unittest.TestCase):
def test_disarm_during_trigger_with_invalid_code(self): def test_disarm_during_trigger_with_invalid_code(self):
"""Test disarming while code is invalid.""" """Test disarming while code is invalid."""
self.assertTrue(alarm_control_panel.setup(self.hass, { self.assertTrue(setup_component(
'alarm_control_panel': { self.hass, alarm_control_panel.DOMAIN,
{'alarm_control_panel': {
'platform': 'manual', 'platform': 'manual',
'name': 'test', 'name': 'test',
'pending_time': 5, 'pending_time': 5,

View file

@ -1,7 +1,7 @@
"""The tests for the location automation.""" """The tests for the location automation."""
import unittest import unittest
from homeassistant.bootstrap import _setup_component from homeassistant.bootstrap import setup_component
from homeassistant.components import automation, zone from homeassistant.components import automation, zone
from tests.common import get_test_home_assistant from tests.common import get_test_home_assistant
@ -14,7 +14,7 @@ class TestAutomationZone(unittest.TestCase):
"""Setup things to be run when tests are started.""" """Setup things to be run when tests are started."""
self.hass = get_test_home_assistant() self.hass = get_test_home_assistant()
self.hass.config.components.append('group') self.hass.config.components.append('group')
zone.setup(self.hass, { assert setup_component(self.hass, zone.DOMAIN, {
'zone': { 'zone': {
'name': 'test', 'name': 'test',
'latitude': 32.880837, 'latitude': 32.880837,
@ -42,7 +42,7 @@ class TestAutomationZone(unittest.TestCase):
}) })
self.hass.block_till_done() self.hass.block_till_done()
assert _setup_component(self.hass, automation.DOMAIN, { assert setup_component(self.hass, automation.DOMAIN, {
automation.DOMAIN: { automation.DOMAIN: {
'trigger': { 'trigger': {
'platform': 'zone', 'platform': 'zone',
@ -100,7 +100,7 @@ class TestAutomationZone(unittest.TestCase):
}) })
self.hass.block_till_done() self.hass.block_till_done()
assert _setup_component(self.hass, automation.DOMAIN, { assert setup_component(self.hass, automation.DOMAIN, {
automation.DOMAIN: { automation.DOMAIN: {
'trigger': { 'trigger': {
'platform': 'zone', 'platform': 'zone',
@ -130,7 +130,7 @@ class TestAutomationZone(unittest.TestCase):
}) })
self.hass.block_till_done() self.hass.block_till_done()
assert _setup_component(self.hass, automation.DOMAIN, { assert setup_component(self.hass, automation.DOMAIN, {
automation.DOMAIN: { automation.DOMAIN: {
'trigger': { 'trigger': {
'platform': 'zone', 'platform': 'zone',
@ -160,7 +160,7 @@ class TestAutomationZone(unittest.TestCase):
}) })
self.hass.block_till_done() self.hass.block_till_done()
assert _setup_component(self.hass, automation.DOMAIN, { assert setup_component(self.hass, automation.DOMAIN, {
automation.DOMAIN: { automation.DOMAIN: {
'trigger': { 'trigger': {
'platform': 'zone', 'platform': 'zone',
@ -190,7 +190,7 @@ class TestAutomationZone(unittest.TestCase):
}) })
self.hass.block_till_done() self.hass.block_till_done()
assert _setup_component(self.hass, automation.DOMAIN, { assert setup_component(self.hass, automation.DOMAIN, {
automation.DOMAIN: { automation.DOMAIN: {
'trigger': { 'trigger': {
'platform': 'event', 'platform': 'event',

View file

@ -4,6 +4,7 @@ import unittest
from homeassistant.util.unit_system import ( from homeassistant.util.unit_system import (
METRIC_SYSTEM, METRIC_SYSTEM,
) )
from homeassistant.bootstrap import setup_component
from homeassistant.components import climate from homeassistant.components import climate
from tests.common import get_test_home_assistant from tests.common import get_test_home_assistant
@ -20,7 +21,8 @@ class TestDemoClimate(unittest.TestCase):
"""Setup things to be run when tests are started.""" """Setup things to be run when tests are started."""
self.hass = get_test_home_assistant() self.hass = get_test_home_assistant()
self.hass.config.units = METRIC_SYSTEM self.hass.config.units = METRIC_SYSTEM
self.assertTrue(climate.setup(self.hass, {'climate': { self.assertTrue(setup_component(self.hass, climate.DOMAIN, {
'climate': {
'platform': 'demo', 'platform': 'demo',
}})) }}))

View file

@ -4,7 +4,7 @@ import unittest
from unittest import mock from unittest import mock
from homeassistant.bootstrap import _setup_component from homeassistant.bootstrap import setup_component
from homeassistant.const import ( from homeassistant.const import (
ATTR_UNIT_OF_MEASUREMENT, ATTR_UNIT_OF_MEASUREMENT,
SERVICE_TURN_OFF, SERVICE_TURN_OFF,
@ -44,12 +44,12 @@ class TestSetupClimateGenericThermostat(unittest.TestCase):
'name': 'test', 'name': 'test',
'target_sensor': ENT_SENSOR 'target_sensor': ENT_SENSOR
} }
self.assertFalse(_setup_component(self.hass, 'climate', { self.assertFalse(setup_component(self.hass, 'climate', {
'climate': config})) 'climate': config}))
def test_valid_conf(self): def test_valid_conf(self):
"""Test set up genreic_thermostat with valid config values.""" """Test set up genreic_thermostat with valid config values."""
self.assertTrue(_setup_component(self.hass, 'climate', self.assertTrue(setup_component(self.hass, 'climate',
{'climate': { {'climate': {
'platform': 'generic_thermostat', 'platform': 'generic_thermostat',
'name': 'test', 'name': 'test',
@ -61,7 +61,7 @@ class TestSetupClimateGenericThermostat(unittest.TestCase):
self.hass.states.set(ENT_SENSOR, 22.0, { self.hass.states.set(ENT_SENSOR, 22.0, {
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS
}) })
climate.setup(self.hass, {'climate': { assert setup_component(self.hass, climate.DOMAIN, {'climate': {
'platform': 'generic_thermostat', 'platform': 'generic_thermostat',
'name': 'test', 'name': 'test',
'heater': ENT_SWITCH, 'heater': ENT_SWITCH,
@ -80,7 +80,7 @@ class TestClimateGenericThermostat(unittest.TestCase):
"""Setup things to be run when tests are started.""" """Setup things to be run when tests are started."""
self.hass = get_test_home_assistant() self.hass = get_test_home_assistant()
self.hass.config.units = METRIC_SYSTEM self.hass.config.units = METRIC_SYSTEM
climate.setup(self.hass, {'climate': { assert setup_component(self.hass, climate.DOMAIN, {'climate': {
'platform': 'generic_thermostat', 'platform': 'generic_thermostat',
'name': 'test', 'name': 'test',
'heater': ENT_SWITCH, 'heater': ENT_SWITCH,
@ -104,7 +104,8 @@ class TestClimateGenericThermostat(unittest.TestCase):
def test_custom_setup_params(self): def test_custom_setup_params(self):
"""Test the setup with custom parameters.""" """Test the setup with custom parameters."""
climate.setup(self.hass, {'climate': { self.hass.config.components.remove(climate.DOMAIN)
assert setup_component(self.hass, climate.DOMAIN, {'climate': {
'platform': 'generic_thermostat', 'platform': 'generic_thermostat',
'name': 'test', 'name': 'test',
'heater': ENT_SWITCH, 'heater': ENT_SWITCH,
@ -229,7 +230,7 @@ class TestClimateGenericThermostatACMode(unittest.TestCase):
"""Setup things to be run when tests are started.""" """Setup things to be run when tests are started."""
self.hass = get_test_home_assistant() self.hass = get_test_home_assistant()
self.hass.config.temperature_unit = TEMP_CELSIUS self.hass.config.temperature_unit = TEMP_CELSIUS
climate.setup(self.hass, {'climate': { assert setup_component(self.hass, climate.DOMAIN, {'climate': {
'platform': 'generic_thermostat', 'platform': 'generic_thermostat',
'name': 'test', 'name': 'test',
'heater': ENT_SWITCH, 'heater': ENT_SWITCH,
@ -319,7 +320,7 @@ class TestClimateGenericThermostatACModeMinCycle(unittest.TestCase):
"""Setup things to be run when tests are started.""" """Setup things to be run when tests are started."""
self.hass = get_test_home_assistant() self.hass = get_test_home_assistant()
self.hass.config.temperature_unit = TEMP_CELSIUS self.hass.config.temperature_unit = TEMP_CELSIUS
climate.setup(self.hass, {'climate': { assert setup_component(self.hass, climate.DOMAIN, {'climate': {
'platform': 'generic_thermostat', 'platform': 'generic_thermostat',
'name': 'test', 'name': 'test',
'heater': ENT_SWITCH, 'heater': ENT_SWITCH,
@ -410,7 +411,7 @@ class TestClimateGenericThermostatMinCycle(unittest.TestCase):
"""Setup things to be run when tests are started.""" """Setup things to be run when tests are started."""
self.hass = get_test_home_assistant() self.hass = get_test_home_assistant()
self.hass.config.temperature_unit = TEMP_CELSIUS self.hass.config.temperature_unit = TEMP_CELSIUS
climate.setup(self.hass, {'climate': { assert setup_component(self.hass, climate.DOMAIN, {'climate': {
'platform': 'generic_thermostat', 'platform': 'generic_thermostat',
'name': 'test', 'name': 'test',
'heater': ENT_SWITCH, 'heater': ENT_SWITCH,

View file

@ -5,6 +5,7 @@ import tempfile
import unittest import unittest
from unittest import mock from unittest import mock
from homeassistant.bootstrap import setup_component
import homeassistant.components.cover as cover import homeassistant.components.cover as cover
from homeassistant.components.cover import ( from homeassistant.components.cover import (
command_line as cmd_rs) command_line as cmd_rs)
@ -52,7 +53,7 @@ class TestCommandCover(unittest.TestCase):
'command_stop': 'echo 0 > {}'.format(path), 'command_stop': 'echo 0 > {}'.format(path),
'value_template': '{{ value }}' 'value_template': '{{ value }}'
} }
self.assertTrue(cover.setup(self.hass, { self.assertTrue(setup_component(self.hass, cover.DOMAIN, {
'cover': { 'cover': {
'platform': 'command_line', 'platform': 'command_line',
'covers': { 'covers': {

View file

@ -3,6 +3,7 @@ import unittest
from datetime import timedelta from datetime import timedelta
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from homeassistant.bootstrap import setup_component
from homeassistant.components import cover from homeassistant.components import cover
from tests.common import get_test_home_assistant, fire_time_changed from tests.common import get_test_home_assistant, fire_time_changed
@ -15,7 +16,7 @@ class TestCoverDemo(unittest.TestCase):
def setUp(self): # pylint: disable=invalid-name def setUp(self): # pylint: disable=invalid-name
"""Setup things to be run when tests are started.""" """Setup things to be run when tests are started."""
self.hass = get_test_home_assistant() self.hass = get_test_home_assistant()
self.assertTrue(cover.setup(self.hass, {'cover': { self.assertTrue(setup_component(self.hass, cover.DOMAIN, {'cover': {
'platform': 'demo', 'platform': 'demo',
}})) }}))

View file

@ -6,6 +6,7 @@ from unittest.mock import patch
from datetime import datetime, timedelta from datetime import datetime, timedelta
import os import os
from homeassistant.bootstrap import setup_component
from homeassistant.loader import get_component from homeassistant.loader import get_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from homeassistant.const import ( from homeassistant.const import (
@ -76,7 +77,8 @@ class TestComponentsDeviceTracker(unittest.TestCase):
'AB:CD:EF:GH:IJ', 'Test name', picture='http://test.picture', 'AB:CD:EF:GH:IJ', 'Test name', picture='http://test.picture',
away_hide=True) away_hide=True)
device_tracker.update_config(self.yaml_devices, dev_id, device) device_tracker.update_config(self.yaml_devices, dev_id, device)
self.assertTrue(device_tracker.setup(self.hass, TEST_PLATFORM)) self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN,
TEST_PLATFORM))
config = device_tracker.load_config(self.yaml_devices, self.hass, config = device_tracker.load_config(self.yaml_devices, self.hass,
device.consider_home)[0] device.consider_home)[0]
self.assertEqual(device.dev_id, config.dev_id) self.assertEqual(device.dev_id, config.dev_id)
@ -120,7 +122,8 @@ class TestComponentsDeviceTracker(unittest.TestCase):
def test_setup_without_yaml_file(self): def test_setup_without_yaml_file(self):
"""Test with no YAML file.""" """Test with no YAML file."""
self.assertTrue(device_tracker.setup(self.hass, TEST_PLATFORM)) self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN,
TEST_PLATFORM))
def test_adding_unknown_device_to_config(self): \ def test_adding_unknown_device_to_config(self): \
# pylint: disable=invalid-name # pylint: disable=invalid-name
@ -129,7 +132,7 @@ class TestComponentsDeviceTracker(unittest.TestCase):
scanner.reset() scanner.reset()
scanner.come_home('DEV1') scanner.come_home('DEV1')
self.assertTrue(device_tracker.setup(self.hass, { self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN, {
device_tracker.DOMAIN: {CONF_PLATFORM: 'test'}})) device_tracker.DOMAIN: {CONF_PLATFORM: 'test'}}))
config = device_tracker.load_config(self.yaml_devices, self.hass, config = device_tracker.load_config(self.yaml_devices, self.hass,
timedelta(seconds=0)) timedelta(seconds=0))
@ -164,8 +167,8 @@ class TestComponentsDeviceTracker(unittest.TestCase):
with patch.dict(device_tracker.DISCOVERY_PLATFORMS, {'test': 'test'}): with patch.dict(device_tracker.DISCOVERY_PLATFORMS, {'test': 'test'}):
with patch.object(scanner, 'scan_devices') as mock_scan: with patch.object(scanner, 'scan_devices') as mock_scan:
self.assertTrue(device_tracker.setup(self.hass, self.assertTrue(setup_component(
TEST_PLATFORM)) self.hass, device_tracker.DOMAIN, TEST_PLATFORM))
fire_service_discovered(self.hass, 'test', {}) fire_service_discovered(self.hass, 'test', {})
self.assertTrue(mock_scan.called) self.assertTrue(mock_scan.called)
@ -180,7 +183,7 @@ class TestComponentsDeviceTracker(unittest.TestCase):
with patch('homeassistant.components.device_tracker.dt_util.utcnow', with patch('homeassistant.components.device_tracker.dt_util.utcnow',
return_value=register_time): return_value=register_time):
self.assertTrue(device_tracker.setup(self.hass, { self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN, {
device_tracker.DOMAIN: { device_tracker.DOMAIN: {
CONF_PLATFORM: 'test', CONF_PLATFORM: 'test',
device_tracker.CONF_CONSIDER_HOME: 59, device_tracker.CONF_CONSIDER_HOME: 59,
@ -211,7 +214,8 @@ class TestComponentsDeviceTracker(unittest.TestCase):
friendly_name, picture, away_hide=True) friendly_name, picture, away_hide=True)
device_tracker.update_config(self.yaml_devices, dev_id, device) device_tracker.update_config(self.yaml_devices, dev_id, device)
self.assertTrue(device_tracker.setup(self.hass, TEST_PLATFORM)) self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN,
TEST_PLATFORM))
attrs = self.hass.states.get(entity_id).attributes attrs = self.hass.states.get(entity_id).attributes
@ -230,7 +234,8 @@ class TestComponentsDeviceTracker(unittest.TestCase):
scanner = get_component('device_tracker.test').SCANNER scanner = get_component('device_tracker.test').SCANNER
scanner.reset() scanner.reset()
self.assertTrue(device_tracker.setup(self.hass, TEST_PLATFORM)) self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN,
TEST_PLATFORM))
self.assertTrue(self.hass.states.get(entity_id) self.assertTrue(self.hass.states.get(entity_id)
.attributes.get(ATTR_HIDDEN)) .attributes.get(ATTR_HIDDEN))
@ -247,7 +252,8 @@ class TestComponentsDeviceTracker(unittest.TestCase):
scanner = get_component('device_tracker.test').SCANNER scanner = get_component('device_tracker.test').SCANNER
scanner.reset() scanner.reset()
self.assertTrue(device_tracker.setup(self.hass, TEST_PLATFORM)) self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN,
TEST_PLATFORM))
state = self.hass.states.get(device_tracker.ENTITY_ID_ALL_DEVICES) state = self.hass.states.get(device_tracker.ENTITY_ID_ALL_DEVICES)
self.assertIsNotNone(state) self.assertIsNotNone(state)
@ -258,7 +264,8 @@ class TestComponentsDeviceTracker(unittest.TestCase):
@patch('homeassistant.components.device_tracker.DeviceTracker.see') @patch('homeassistant.components.device_tracker.DeviceTracker.see')
def test_see_service(self, mock_see): def test_see_service(self, mock_see):
"""Test the see service with a unicode dev_id and NO MAC.""" """Test the see service with a unicode dev_id and NO MAC."""
self.assertTrue(device_tracker.setup(self.hass, TEST_PLATFORM)) self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN,
TEST_PLATFORM))
params = { params = {
'dev_id': 'some_device', 'dev_id': 'some_device',
'host_name': 'example.com', 'host_name': 'example.com',
@ -281,7 +288,8 @@ class TestComponentsDeviceTracker(unittest.TestCase):
def test_not_write_duplicate_yaml_keys(self): \ def test_not_write_duplicate_yaml_keys(self): \
# pylint: disable=invalid-name # pylint: disable=invalid-name
"""Test that the device tracker will not generate invalid YAML.""" """Test that the device tracker will not generate invalid YAML."""
self.assertTrue(device_tracker.setup(self.hass, TEST_PLATFORM)) self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN,
TEST_PLATFORM))
device_tracker.see(self.hass, 'mac_1', host_name='hello') device_tracker.see(self.hass, 'mac_1', host_name='hello')
device_tracker.see(self.hass, 'mac_2', host_name='hello') device_tracker.see(self.hass, 'mac_2', host_name='hello')
@ -294,7 +302,8 @@ class TestComponentsDeviceTracker(unittest.TestCase):
def test_not_allow_invalid_dev_id(self): # pylint: disable=invalid-name def test_not_allow_invalid_dev_id(self): # pylint: disable=invalid-name
"""Test that the device tracker will not allow invalid dev ids.""" """Test that the device tracker will not allow invalid dev ids."""
self.assertTrue(device_tracker.setup(self.hass, TEST_PLATFORM)) self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN,
TEST_PLATFORM))
device_tracker.see(self.hass, dev_id='hello-world') device_tracker.see(self.hass, dev_id='hello-world')
@ -329,6 +338,6 @@ class TestComponentsDeviceTracker(unittest.TestCase):
@patch('homeassistant.components.device_tracker.log_exception') @patch('homeassistant.components.device_tracker.log_exception')
def test_config_failure(self, mock_ex): def test_config_failure(self, mock_ex):
"""Test that the device tracker see failures.""" """Test that the device tracker see failures."""
device_tracker.setup(self.hass, {device_tracker.DOMAIN: { assert not setup_component(self.hass, device_tracker.DOMAIN,
{device_tracker.DOMAIN: {
device_tracker.CONF_CONSIDER_HOME: -1}}) device_tracker.CONF_CONSIDER_HOME: -1}})
assert mock_ex.call_count == 1

View file

@ -5,6 +5,7 @@ import unittest
from collections import defaultdict from collections import defaultdict
from homeassistant.bootstrap import setup_component
from homeassistant.components import device_tracker from homeassistant.components import device_tracker
from homeassistant.const import (STATE_NOT_HOME, CONF_PLATFORM) from homeassistant.const import (STATE_NOT_HOME, CONF_PLATFORM)
import homeassistant.components.device_tracker.owntracks as owntracks import homeassistant.components.device_tracker.owntracks as owntracks
@ -191,7 +192,7 @@ class TestDeviceTrackerOwnTracks(unittest.TestCase):
"""Setup things to be run when tests are started.""" """Setup things to be run when tests are started."""
self.hass = get_test_home_assistant() self.hass = get_test_home_assistant()
mock_mqtt_component(self.hass) mock_mqtt_component(self.hass)
self.assertTrue(device_tracker.setup(self.hass, { self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN, {
device_tracker.DOMAIN: { device_tracker.DOMAIN: {
CONF_PLATFORM: 'owntracks', CONF_PLATFORM: 'owntracks',
CONF_MAX_GPS_ACCURACY: 200, CONF_MAX_GPS_ACCURACY: 200,

View file

@ -2,6 +2,7 @@
import unittest import unittest
from homeassistant.bootstrap import setup_component
from homeassistant.components import fan from homeassistant.components import fan
from homeassistant.components.fan.demo import FAN_ENTITY_ID from homeassistant.components.fan.demo import FAN_ENTITY_ID
from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.const import STATE_OFF, STATE_ON
@ -19,7 +20,7 @@ class TestDemoFan(unittest.TestCase):
def setUp(self): def setUp(self):
"""Initialize unit test data.""" """Initialize unit test data."""
self.hass = get_test_home_assistant() self.hass = get_test_home_assistant()
self.assertTrue(fan.setup(self.hass, {'fan': { self.assertTrue(setup_component(self.hass, fan.DOMAIN, {'fan': {
'platform': 'demo', 'platform': 'demo',
}})) }}))
self.hass.block_till_done() self.hass.block_till_done()

View file

@ -1,6 +1,7 @@
"""The tests for the Demo Garage door platform.""" """The tests for the Demo Garage door platform."""
import unittest import unittest
from homeassistant.bootstrap import setup_component
import homeassistant.components.garage_door as gd import homeassistant.components.garage_door as gd
from tests.common import get_test_home_assistant from tests.common import get_test_home_assistant
@ -16,7 +17,7 @@ class TestGarageDoorDemo(unittest.TestCase):
def setUp(self): # pylint: disable=invalid-name def setUp(self): # pylint: disable=invalid-name
"""Setup things to be run when tests are started.""" """Setup things to be run when tests are started."""
self.hass = get_test_home_assistant() self.hass = get_test_home_assistant()
self.assertTrue(gd.setup(self.hass, { self.assertTrue(setup_component(self.hass, gd.DOMAIN, {
'garage_door': { 'garage_door': {
'platform': 'demo' 'platform': 'demo'
} }

View file

@ -3,6 +3,7 @@
import unittest import unittest
import os import os
from homeassistant.bootstrap import setup_component
import homeassistant.loader as loader import homeassistant.loader as loader
from homeassistant.const import ( from homeassistant.const import (
ATTR_ENTITY_ID, STATE_ON, STATE_OFF, CONF_PLATFORM, ATTR_ENTITY_ID, STATE_ON, STATE_OFF, CONF_PLATFORM,
@ -112,7 +113,8 @@ class TestLight(unittest.TestCase):
platform.init() platform.init()
self.assertTrue( self.assertTrue(
light.setup(self.hass, {light.DOMAIN: {CONF_PLATFORM: 'test'}})) setup_component(self.hass, light.DOMAIN,
{light.DOMAIN: {CONF_PLATFORM: 'test'}}))
dev1, dev2, dev3 = platform.DEVICES dev1, dev2, dev3 = platform.DEVICES
@ -250,8 +252,8 @@ class TestLight(unittest.TestCase):
user_file.write('id,x,y,brightness\n') user_file.write('id,x,y,brightness\n')
user_file.write('I,WILL,NOT,WORK\n') user_file.write('I,WILL,NOT,WORK\n')
self.assertFalse(light.setup( self.assertFalse(setup_component(
self.hass, {light.DOMAIN: {CONF_PLATFORM: 'test'}} self.hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: 'test'}}
)) ))
def test_light_profiles(self): def test_light_profiles(self):
@ -265,8 +267,8 @@ class TestLight(unittest.TestCase):
user_file.write('id,x,y,brightness\n') user_file.write('id,x,y,brightness\n')
user_file.write('test,.4,.6,100\n') user_file.write('test,.4,.6,100\n')
self.assertTrue(light.setup( self.assertTrue(setup_component(
self.hass, {light.DOMAIN: {CONF_PLATFORM: 'test'}} self.hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: 'test'}}
)) ))
dev1, dev2, dev3 = platform.DEVICES dev1, dev2, dev3 = platform.DEVICES

View file

@ -1,6 +1,7 @@
"""The tests for the Demo lock platform.""" """The tests for the Demo lock platform."""
import unittest import unittest
from homeassistant.bootstrap import setup_component
from homeassistant.components import lock from homeassistant.components import lock
from tests.common import get_test_home_assistant from tests.common import get_test_home_assistant
@ -16,7 +17,7 @@ class TestLockDemo(unittest.TestCase):
def setUp(self): # pylint: disable=invalid-name def setUp(self): # pylint: disable=invalid-name
"""Setup things to be run when tests are started.""" """Setup things to be run when tests are started."""
self.hass = get_test_home_assistant() self.hass = get_test_home_assistant()
self.assertTrue(lock.setup(self.hass, { self.assertTrue(setup_component(self.hass, lock.DOMAIN, {
'lock': { 'lock': {
'platform': 'demo' 'platform': 'demo'
} }

View file

@ -1,7 +1,8 @@
"""The tests for the Demo Media player platform.""" """The tests for the Demo Media player platform."""
import unittest import unittest
from unittest.mock import patch from unittest.mock import patch
from homeassistant import bootstrap
from homeassistant.bootstrap import setup_component
from homeassistant.const import HTTP_HEADER_HA_AUTH from homeassistant.const import HTTP_HEADER_HA_AUTH
import homeassistant.components.media_player as mp import homeassistant.components.media_player as mp
import homeassistant.components.http as http import homeassistant.components.http as http
@ -27,7 +28,7 @@ def setUpModule(): # pylint: disable=invalid-name
global hass global hass
hass = get_test_home_assistant() hass = get_test_home_assistant()
bootstrap.setup_component(hass, http.DOMAIN, { setup_component(hass, http.DOMAIN, {
http.DOMAIN: { http.DOMAIN: {
http.CONF_SERVER_PORT: SERVER_PORT, http.CONF_SERVER_PORT: SERVER_PORT,
http.CONF_API_PASSWORD: API_PASSWORD, http.CONF_API_PASSWORD: API_PASSWORD,
@ -49,13 +50,19 @@ class TestDemoMediaPlayer(unittest.TestCase):
def setUp(self): # pylint: disable=invalid-name def setUp(self): # pylint: disable=invalid-name
"""Setup things to be run when tests are started.""" """Setup things to be run when tests are started."""
self.hass = hass self.hass = hass
try:
self.hass.config.components.remove(mp.DOMAIN)
except ValueError:
pass
def test_source_select(self): def test_source_select(self):
"""Test the input source service.""" """Test the input source service."""
entity_id = 'media_player.lounge_room' entity_id = 'media_player.lounge_room'
assert mp.setup(self.hass, {'media_player': {'platform': 'demo'}}) assert setup_component(
self.hass, mp.DOMAIN,
{'media_player': {'platform': 'demo'}})
state = self.hass.states.get(entity_id) state = self.hass.states.get(entity_id)
assert 'dvd' == state.attributes.get('source') assert 'dvd' == state.attributes.get('source')
@ -71,7 +78,9 @@ class TestDemoMediaPlayer(unittest.TestCase):
def test_clear_playlist(self): def test_clear_playlist(self):
"""Test clear playlist.""" """Test clear playlist."""
assert mp.setup(self.hass, {'media_player': {'platform': 'demo'}}) assert setup_component(
self.hass, mp.DOMAIN,
{'media_player': {'platform': 'demo'}})
assert self.hass.states.is_state(entity_id, 'playing') assert self.hass.states.is_state(entity_id, 'playing')
mp.clear_playlist(self.hass, entity_id) mp.clear_playlist(self.hass, entity_id)
@ -80,8 +89,11 @@ class TestDemoMediaPlayer(unittest.TestCase):
def test_volume_services(self): def test_volume_services(self):
"""Test the volume service.""" """Test the volume service."""
assert mp.setup(self.hass, {'media_player': {'platform': 'demo'}}) assert setup_component(
self.hass, mp.DOMAIN,
{'media_player': {'platform': 'demo'}})
state = self.hass.states.get(entity_id) state = self.hass.states.get(entity_id)
print(state)
assert 1.0 == state.attributes.get('volume_level') assert 1.0 == state.attributes.get('volume_level')
mp.set_volume_level(self.hass, None, entity_id) mp.set_volume_level(self.hass, None, entity_id)
@ -118,7 +130,9 @@ class TestDemoMediaPlayer(unittest.TestCase):
def test_turning_off_and_on(self): def test_turning_off_and_on(self):
"""Test turn_on and turn_off.""" """Test turn_on and turn_off."""
assert mp.setup(self.hass, {'media_player': {'platform': 'demo'}}) assert setup_component(
self.hass, mp.DOMAIN,
{'media_player': {'platform': 'demo'}})
assert self.hass.states.is_state(entity_id, 'playing') assert self.hass.states.is_state(entity_id, 'playing')
mp.turn_off(self.hass, entity_id) mp.turn_off(self.hass, entity_id)
@ -137,7 +151,9 @@ class TestDemoMediaPlayer(unittest.TestCase):
def test_playing_pausing(self): def test_playing_pausing(self):
"""Test media_pause.""" """Test media_pause."""
assert mp.setup(self.hass, {'media_player': {'platform': 'demo'}}) assert setup_component(
self.hass, mp.DOMAIN,
{'media_player': {'platform': 'demo'}})
assert self.hass.states.is_state(entity_id, 'playing') assert self.hass.states.is_state(entity_id, 'playing')
mp.media_pause(self.hass, entity_id) mp.media_pause(self.hass, entity_id)
@ -158,7 +174,9 @@ class TestDemoMediaPlayer(unittest.TestCase):
def test_prev_next_track(self): def test_prev_next_track(self):
"""Test media_next_track and media_previous_track .""" """Test media_next_track and media_previous_track ."""
assert mp.setup(self.hass, {'media_player': {'platform': 'demo'}}) assert setup_component(
self.hass, mp.DOMAIN,
{'media_player': {'platform': 'demo'}})
state = self.hass.states.get(entity_id) state = self.hass.states.get(entity_id)
assert 1 == state.attributes.get('media_track') assert 1 == state.attributes.get('media_track')
assert 0 == (mp.SUPPORT_PREVIOUS_TRACK & assert 0 == (mp.SUPPORT_PREVIOUS_TRACK &
@ -185,7 +203,9 @@ class TestDemoMediaPlayer(unittest.TestCase):
assert 0 < (mp.SUPPORT_PREVIOUS_TRACK & assert 0 < (mp.SUPPORT_PREVIOUS_TRACK &
state.attributes.get('supported_media_commands')) state.attributes.get('supported_media_commands'))
assert mp.setup(self.hass, {'media_player': {'platform': 'demo'}}) assert setup_component(
self.hass, mp.DOMAIN,
{'media_player': {'platform': 'demo'}})
ent_id = 'media_player.lounge_room' ent_id = 'media_player.lounge_room'
state = self.hass.states.get(ent_id) state = self.hass.states.get(ent_id)
assert 1 == state.attributes.get('media_episode') assert 1 == state.attributes.get('media_episode')
@ -212,7 +232,9 @@ class TestDemoMediaPlayer(unittest.TestCase):
fake_picture_data = 'test.test' fake_picture_data = 'test.test'
m.get('https://graph.facebook.com/v2.5/107771475912710/' m.get('https://graph.facebook.com/v2.5/107771475912710/'
'picture?type=large', text=fake_picture_data) 'picture?type=large', text=fake_picture_data)
assert mp.setup(self.hass, {'media_player': {'platform': 'demo'}}) assert setup_component(
self.hass, mp.DOMAIN,
{'media_player': {'platform': 'demo'}})
assert self.hass.states.is_state(entity_id, 'playing') assert self.hass.states.is_state(entity_id, 'playing')
state = self.hass.states.get(entity_id) state = self.hass.states.get(entity_id)
req = requests.get(HTTP_BASE_URL + req = requests.get(HTTP_BASE_URL +
@ -223,7 +245,9 @@ class TestDemoMediaPlayer(unittest.TestCase):
'media_seek') 'media_seek')
def test_play_media(self, mock_seek): def test_play_media(self, mock_seek):
"""Test play_media .""" """Test play_media ."""
assert mp.setup(self.hass, {'media_player': {'platform': 'demo'}}) assert setup_component(
self.hass, mp.DOMAIN,
{'media_player': {'platform': 'demo'}})
ent_id = 'media_player.living_room' ent_id = 'media_player.living_room'
state = self.hass.states.get(ent_id) state = self.hass.states.get(ent_id)
assert 0 < (mp.SUPPORT_PLAY_MEDIA & assert 0 < (mp.SUPPORT_PLAY_MEDIA &

View file

@ -4,8 +4,8 @@ import tempfile
import unittest import unittest
from unittest.mock import patch from unittest.mock import patch
from homeassistant.bootstrap import setup_component
import homeassistant.components.notify as notify import homeassistant.components.notify as notify
from homeassistant import bootstrap
from tests.common import get_test_home_assistant from tests.common import get_test_home_assistant
@ -22,7 +22,7 @@ class TestCommandLine(unittest.TestCase):
def test_setup(self): def test_setup(self):
"""Test setup.""" """Test setup."""
assert bootstrap.setup_component(self.hass, 'notify', { assert setup_component(self.hass, 'notify', {
'notify': { 'notify': {
'name': 'test', 'name': 'test',
'platform': 'command_line', 'platform': 'command_line',
@ -31,7 +31,7 @@ class TestCommandLine(unittest.TestCase):
def test_bad_config(self): def test_bad_config(self):
"""Test set up the platform with bad/missing configuration.""" """Test set up the platform with bad/missing configuration."""
self.assertFalse(notify.setup(self.hass, { self.assertFalse(setup_component(self.hass, notify.DOMAIN, {
'notify': { 'notify': {
'name': 'test', 'name': 'test',
'platform': 'bad_platform', 'platform': 'bad_platform',
@ -43,7 +43,7 @@ class TestCommandLine(unittest.TestCase):
with tempfile.TemporaryDirectory() as tempdirname: with tempfile.TemporaryDirectory() as tempdirname:
filename = os.path.join(tempdirname, 'message.txt') filename = os.path.join(tempdirname, 'message.txt')
message = 'one, two, testing, testing' message = 'one, two, testing, testing'
self.assertTrue(notify.setup(self.hass, { self.assertTrue(setup_component(self.hass, notify.DOMAIN, {
'notify': { 'notify': {
'name': 'test', 'name': 'test',
'platform': 'command_line', 'platform': 'command_line',
@ -63,7 +63,7 @@ class TestCommandLine(unittest.TestCase):
@patch('homeassistant.components.notify.command_line._LOGGER.error') @patch('homeassistant.components.notify.command_line._LOGGER.error')
def test_error_for_none_zero_exit_code(self, mock_error): def test_error_for_none_zero_exit_code(self, mock_error):
"""Test if an error is logged for non zero exit codes.""" """Test if an error is logged for non zero exit codes."""
self.assertTrue(notify.setup(self.hass, { self.assertTrue(setup_component(self.hass, notify.DOMAIN, {
'notify': { 'notify': {
'name': 'test', 'name': 'test',
'platform': 'command_line', 'platform': 'command_line',

View file

@ -2,6 +2,7 @@
import tempfile import tempfile
import unittest import unittest
from homeassistant.bootstrap import setup_component
import homeassistant.components.notify as notify import homeassistant.components.notify as notify
from homeassistant.components.notify import demo from homeassistant.components.notify import demo
from homeassistant.helpers import script from homeassistant.helpers import script
@ -16,7 +17,7 @@ class TestNotifyDemo(unittest.TestCase):
def setUp(self): # pylint: disable=invalid-name def setUp(self): # pylint: disable=invalid-name
"""Setup things to be run when tests are started.""" """Setup things to be run when tests are started."""
self.hass = get_test_home_assistant() self.hass = get_test_home_assistant()
self.assertTrue(notify.setup(self.hass, { self.assertTrue(setup_component(self.hass, notify.DOMAIN, {
'notify': { 'notify': {
'platform': 'demo' 'platform': 'demo'
} }

View file

@ -4,6 +4,7 @@ import unittest
import tempfile import tempfile
from unittest.mock import patch from unittest.mock import patch
from homeassistant.bootstrap import setup_component
import homeassistant.components.notify as notify import homeassistant.components.notify as notify
from homeassistant.components.notify import ( from homeassistant.components.notify import (
ATTR_TITLE_DEFAULT) ATTR_TITLE_DEFAULT)
@ -41,7 +42,7 @@ class TestNotifyFile(unittest.TestCase):
with tempfile.TemporaryDirectory() as tempdirname: with tempfile.TemporaryDirectory() as tempdirname:
filename = os.path.join(tempdirname, 'notify.txt') filename = os.path.join(tempdirname, 'notify.txt')
message = 'one, two, testing, testing' message = 'one, two, testing, testing'
self.assertTrue(notify.setup(self.hass, { self.assertTrue(setup_component(self.hass, notify.DOMAIN, {
'notify': { 'notify': {
'name': 'test', 'name': 'test',
'platform': 'file', 'platform': 'file',

View file

@ -1,6 +1,7 @@
"""The tests for the notify.group platform.""" """The tests for the notify.group platform."""
import unittest import unittest
from homeassistant.bootstrap import setup_component
import homeassistant.components.notify as notify import homeassistant.components.notify as notify
from homeassistant.components.notify import group from homeassistant.components.notify import group
@ -14,17 +15,14 @@ class TestNotifyGroup(unittest.TestCase):
"""Setup things to be run when tests are started.""" """Setup things to be run when tests are started."""
self.hass = get_test_home_assistant() self.hass = get_test_home_assistant()
self.events = [] self.events = []
self.assertTrue(notify.setup(self.hass, { self.assertTrue(setup_component(self.hass, notify.DOMAIN, {
'notify': { 'notify': [{
'name': 'demo1', 'name': 'demo1',
'platform': 'demo' 'platform': 'demo'
} }, {
}))
self.assertTrue(notify.setup(self.hass, {
'notify': {
'name': 'demo2', 'name': 'demo2',
'platform': 'demo' 'platform': 'demo'
} }]
})) }))
self.service = group.get_service(self.hass, {'services': [ self.service = group.get_service(self.hass, {'services': [

View file

@ -4,6 +4,7 @@ import unittest.mock as mock
import requests import requests
from homeassistant.bootstrap import setup_component
import homeassistant.components.sensor as sensor import homeassistant.components.sensor as sensor
import homeassistant.components.sensor.mfi as mfi import homeassistant.components.sensor.mfi as mfi
from homeassistant.const import TEMP_CELSIUS from homeassistant.const import TEMP_CELSIUS
@ -69,7 +70,7 @@ class TestMfiSensorSetup(unittest.TestCase):
"""Test setup with minimum configuration.""" """Test setup with minimum configuration."""
config = dict(self.GOOD_CONFIG) config = dict(self.GOOD_CONFIG)
del config[self.THING]['port'] del config[self.THING]['port']
assert self.COMPONENT.setup(self.hass, config) assert setup_component(self.hass, self.COMPONENT.DOMAIN, config)
mock_client.assert_called_once_with( mock_client.assert_called_once_with(
'foo', 'user', 'pass', port=6443, use_tls=True, verify=True) 'foo', 'user', 'pass', port=6443, use_tls=True, verify=True)
@ -78,7 +79,7 @@ class TestMfiSensorSetup(unittest.TestCase):
"""Test setup with port.""" """Test setup with port."""
config = dict(self.GOOD_CONFIG) config = dict(self.GOOD_CONFIG)
config[self.THING]['port'] = 6123 config[self.THING]['port'] = 6123
assert self.COMPONENT.setup(self.hass, config) assert setup_component(self.hass, self.COMPONENT.DOMAIN, config)
mock_client.assert_called_once_with( mock_client.assert_called_once_with(
'foo', 'user', 'pass', port=6123, use_tls=True, verify=True) 'foo', 'user', 'pass', port=6123, use_tls=True, verify=True)
@ -89,7 +90,7 @@ class TestMfiSensorSetup(unittest.TestCase):
del config[self.THING]['port'] del config[self.THING]['port']
config[self.THING]['ssl'] = False config[self.THING]['ssl'] = False
config[self.THING]['verify_ssl'] = False config[self.THING]['verify_ssl'] = False
assert self.COMPONENT.setup(self.hass, config) assert setup_component(self.hass, self.COMPONENT.DOMAIN, config)
mock_client.assert_called_once_with( mock_client.assert_called_once_with(
'foo', 'user', 'pass', port=6080, use_tls=False, verify=False) 'foo', 'user', 'pass', port=6080, use_tls=False, verify=False)

View file

@ -1,6 +1,7 @@
"""The tests for the MoldIndicator sensor.""" """The tests for the MoldIndicator sensor."""
import unittest import unittest
from homeassistant.bootstrap import setup_component
import homeassistant.components.sensor as sensor import homeassistant.components.sensor as sensor
from homeassistant.components.sensor.mold_indicator import (ATTR_DEWPOINT, from homeassistant.components.sensor.mold_indicator import (ATTR_DEWPOINT,
ATTR_CRITICAL_TEMP) ATTR_CRITICAL_TEMP)
@ -22,7 +23,6 @@ class TestSensorMoldIndicator(unittest.TestCase):
{ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS}) {ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS})
self.hass.states.set('test.indoorhumidity', '50', self.hass.states.set('test.indoorhumidity', '50',
{ATTR_UNIT_OF_MEASUREMENT: '%'}) {ATTR_UNIT_OF_MEASUREMENT: '%'})
self.hass.block_till_done()
def tearDown(self): def tearDown(self):
"""Stop down everything that was started.""" """Stop down everything that was started."""
@ -30,7 +30,7 @@ class TestSensorMoldIndicator(unittest.TestCase):
def test_setup(self): def test_setup(self):
"""Test the mold indicator sensor setup.""" """Test the mold indicator sensor setup."""
self.assertTrue(sensor.setup(self.hass, { self.assertTrue(setup_component(self.hass, sensor.DOMAIN, {
'sensor': { 'sensor': {
'platform': 'mold_indicator', 'platform': 'mold_indicator',
'indoor_temp_sensor': 'test.indoortemp', 'indoor_temp_sensor': 'test.indoortemp',
@ -53,7 +53,7 @@ class TestSensorMoldIndicator(unittest.TestCase):
self.hass.states.set('test.indoorhumidity', '0', self.hass.states.set('test.indoorhumidity', '0',
{ATTR_UNIT_OF_MEASUREMENT: '%'}) {ATTR_UNIT_OF_MEASUREMENT: '%'})
self.assertTrue(sensor.setup(self.hass, { self.assertTrue(setup_component(self.hass, sensor.DOMAIN, {
'sensor': { 'sensor': {
'platform': 'mold_indicator', 'platform': 'mold_indicator',
'indoor_temp_sensor': 'test.indoortemp', 'indoor_temp_sensor': 'test.indoortemp',
@ -68,7 +68,7 @@ class TestSensorMoldIndicator(unittest.TestCase):
def test_calculation(self): def test_calculation(self):
"""Test the mold indicator internal calculations.""" """Test the mold indicator internal calculations."""
self.assertTrue(sensor.setup(self.hass, { self.assertTrue(setup_component(self.hass, sensor.DOMAIN, {
'sensor': { 'sensor': {
'platform': 'mold_indicator', 'platform': 'mold_indicator',
'indoor_temp_sensor': 'test.indoortemp', 'indoor_temp_sensor': 'test.indoortemp',
@ -100,7 +100,7 @@ class TestSensorMoldIndicator(unittest.TestCase):
def test_sensor_changed(self): def test_sensor_changed(self):
"""Test the sensor_changed function.""" """Test the sensor_changed function."""
self.assertTrue(sensor.setup(self.hass, { self.assertTrue(setup_component(self.hass, sensor.DOMAIN, {
'sensor': { 'sensor': {
'platform': 'mold_indicator', 'platform': 'mold_indicator',
'indoor_temp_sensor': 'test.indoortemp', 'indoor_temp_sensor': 'test.indoortemp',

View file

@ -4,6 +4,7 @@ import datetime
import unittest import unittest
from unittest.mock import patch from unittest.mock import patch
from homeassistant.bootstrap import setup_component
import homeassistant.components.sensor as sensor import homeassistant.components.sensor as sensor
from homeassistant.components.mqtt import (CONF_STATE_TOPIC, CONF_QOS, from homeassistant.components.mqtt import (CONF_STATE_TOPIC, CONF_QOS,
DEFAULT_QOS) DEFAULT_QOS)
@ -52,7 +53,7 @@ class TestMQTTRoomSensor(unittest.TestCase):
"""Setup things to be run when tests are started.""" """Setup things to be run when tests are started."""
self.hass = get_test_home_assistant() self.hass = get_test_home_assistant()
mock_mqtt_component(self.hass) mock_mqtt_component(self.hass)
self.assertTrue(sensor.setup(self.hass, { self.assertTrue(setup_component(self.hass, sensor.DOMAIN, {
sensor.DOMAIN: { sensor.DOMAIN: {
CONF_PLATFORM: 'mqtt_room', CONF_PLATFORM: 'mqtt_room',
CONF_NAME: NAME, CONF_NAME: NAME,

View file

@ -4,6 +4,7 @@ import os
import tempfile import tempfile
import unittest import unittest
from homeassistant.bootstrap import setup_component
from homeassistant.const import STATE_ON, STATE_OFF from homeassistant.const import STATE_ON, STATE_OFF
import homeassistant.components.switch as switch import homeassistant.components.switch as switch
import homeassistant.components.switch.command_line as command_line import homeassistant.components.switch.command_line as command_line
@ -30,7 +31,7 @@ class TestCommandSwitch(unittest.TestCase):
'command_on': 'echo 1 > {}'.format(path), 'command_on': 'echo 1 > {}'.format(path),
'command_off': 'echo 0 > {}'.format(path), 'command_off': 'echo 0 > {}'.format(path),
} }
self.assertTrue(switch.setup(self.hass, { self.assertTrue(setup_component(self.hass, switch.DOMAIN, {
'switch': { 'switch': {
'platform': 'command_line', 'platform': 'command_line',
'switches': { 'switches': {
@ -64,7 +65,7 @@ class TestCommandSwitch(unittest.TestCase):
'command_off': 'echo 0 > {}'.format(path), 'command_off': 'echo 0 > {}'.format(path),
'value_template': '{{ value=="1" }}' 'value_template': '{{ value=="1" }}'
} }
self.assertTrue(switch.setup(self.hass, { self.assertTrue(setup_component(self.hass, switch.DOMAIN, {
'switch': { 'switch': {
'platform': 'command_line', 'platform': 'command_line',
'switches': { 'switches': {
@ -100,7 +101,7 @@ class TestCommandSwitch(unittest.TestCase):
'command_off': 'echo \'{}\' > {}'.format(offcmd, path), 'command_off': 'echo \'{}\' > {}'.format(offcmd, path),
'value_template': '{{ value_json.status=="ok" }}' 'value_template': '{{ value_json.status=="ok" }}'
} }
self.assertTrue(switch.setup(self.hass, { self.assertTrue(setup_component(self.hass, switch.DOMAIN, {
'switch': { 'switch': {
'platform': 'command_line', 'platform': 'command_line',
'switches': { 'switches': {
@ -133,7 +134,7 @@ class TestCommandSwitch(unittest.TestCase):
'command_on': 'echo 1 > {}'.format(path), 'command_on': 'echo 1 > {}'.format(path),
'command_off': 'echo 0 > {}'.format(path), 'command_off': 'echo 0 > {}'.format(path),
} }
self.assertTrue(switch.setup(self.hass, { self.assertTrue(setup_component(self.hass, switch.DOMAIN, {
'switch': { 'switch': {
'platform': 'command_line', 'platform': 'command_line',
'switches': { 'switches': {

View file

@ -3,7 +3,7 @@ import unittest
from datetime import timedelta from datetime import timedelta
from unittest.mock import patch from unittest.mock import patch
from homeassistant.bootstrap import _setup_component, setup_component from homeassistant.bootstrap import setup_component
from homeassistant.components import switch, light from homeassistant.components import switch, light
from homeassistant.const import CONF_PLATFORM, STATE_ON, SERVICE_TURN_ON from homeassistant.const import CONF_PLATFORM, STATE_ON, SERVICE_TURN_ON
import homeassistant.loader as loader import homeassistant.loader as loader
@ -25,7 +25,7 @@ class TestSwitchFlux(unittest.TestCase):
def test_valid_config(self): def test_valid_config(self):
"""Test configuration.""" """Test configuration."""
assert _setup_component(self.hass, 'switch', { assert setup_component(self.hass, 'switch', {
'switch': { 'switch': {
'platform': 'flux', 'platform': 'flux',
'name': 'flux', 'name': 'flux',
@ -35,7 +35,7 @@ class TestSwitchFlux(unittest.TestCase):
def test_valid_config_with_info(self): def test_valid_config_with_info(self):
"""Test configuration.""" """Test configuration."""
assert _setup_component(self.hass, 'switch', { assert setup_component(self.hass, 'switch', {
'switch': { 'switch': {
'platform': 'flux', 'platform': 'flux',
'name': 'flux', 'name': 'flux',
@ -50,7 +50,7 @@ class TestSwitchFlux(unittest.TestCase):
def test_valid_config_no_name(self): def test_valid_config_no_name(self):
"""Test configuration.""" """Test configuration."""
assert _setup_component(self.hass, 'switch', { assert setup_component(self.hass, 'switch', {
'switch': { 'switch': {
'platform': 'flux', 'platform': 'flux',
'lights': ['light.desk', 'light.lamp'] 'lights': ['light.desk', 'light.lamp']
@ -59,7 +59,7 @@ class TestSwitchFlux(unittest.TestCase):
def test_invalid_config_no_lights(self): def test_invalid_config_no_lights(self):
"""Test configuration.""" """Test configuration."""
assert not _setup_component(self.hass, 'switch', { assert not setup_component(self.hass, 'switch', {
'switch': { 'switch': {
'platform': 'flux', 'platform': 'flux',
'name': 'flux' 'name': 'flux'
@ -71,7 +71,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test') platform = loader.get_component('light.test')
platform.init() platform.init()
self.assertTrue( self.assertTrue(
light.setup(self.hass, {light.DOMAIN: {CONF_PLATFORM: 'test'}})) setup_component(self.hass, light.DOMAIN,
{light.DOMAIN: {CONF_PLATFORM: 'test'}}))
dev1 = platform.DEVICES[0] dev1 = platform.DEVICES[0]
@ -110,7 +111,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test') platform = loader.get_component('light.test')
platform.init() platform.init()
self.assertTrue( self.assertTrue(
light.setup(self.hass, {light.DOMAIN: {CONF_PLATFORM: 'test'}})) setup_component(self.hass, light.DOMAIN,
{light.DOMAIN: {CONF_PLATFORM: 'test'}}))
dev1 = platform.DEVICES[0] dev1 = platform.DEVICES[0]
@ -154,7 +156,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test') platform = loader.get_component('light.test')
platform.init() platform.init()
self.assertTrue( self.assertTrue(
light.setup(self.hass, {light.DOMAIN: {CONF_PLATFORM: 'test'}})) setup_component(self.hass, light.DOMAIN,
{light.DOMAIN: {CONF_PLATFORM: 'test'}}))
dev1 = platform.DEVICES[0] dev1 = platform.DEVICES[0]
@ -198,7 +201,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test') platform = loader.get_component('light.test')
platform.init() platform.init()
self.assertTrue( self.assertTrue(
light.setup(self.hass, {light.DOMAIN: {CONF_PLATFORM: 'test'}})) setup_component(self.hass, light.DOMAIN,
{light.DOMAIN: {CONF_PLATFORM: 'test'}}))
dev1 = platform.DEVICES[0] dev1 = platform.DEVICES[0]
@ -242,7 +246,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test') platform = loader.get_component('light.test')
platform.init() platform.init()
self.assertTrue( self.assertTrue(
light.setup(self.hass, {light.DOMAIN: {CONF_PLATFORM: 'test'}})) setup_component(self.hass, light.DOMAIN,
{light.DOMAIN: {CONF_PLATFORM: 'test'}}))
dev1 = platform.DEVICES[0] dev1 = platform.DEVICES[0]
@ -286,7 +291,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test') platform = loader.get_component('light.test')
platform.init() platform.init()
self.assertTrue( self.assertTrue(
light.setup(self.hass, {light.DOMAIN: {CONF_PLATFORM: 'test'}})) setup_component(self.hass, light.DOMAIN,
{light.DOMAIN: {CONF_PLATFORM: 'test'}}))
dev1 = platform.DEVICES[0] dev1 = platform.DEVICES[0]
@ -332,7 +338,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test') platform = loader.get_component('light.test')
platform.init() platform.init()
self.assertTrue( self.assertTrue(
light.setup(self.hass, {light.DOMAIN: {CONF_PLATFORM: 'test'}})) setup_component(self.hass, light.DOMAIN,
{light.DOMAIN: {CONF_PLATFORM: 'test'}}))
dev1 = platform.DEVICES[0] dev1 = platform.DEVICES[0]
@ -378,7 +385,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test') platform = loader.get_component('light.test')
platform.init() platform.init()
self.assertTrue( self.assertTrue(
light.setup(self.hass, {light.DOMAIN: {CONF_PLATFORM: 'test'}})) setup_component(self.hass, light.DOMAIN,
{light.DOMAIN: {CONF_PLATFORM: 'test'}}))
dev1 = platform.DEVICES[0] dev1 = platform.DEVICES[0]
@ -422,7 +430,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test') platform = loader.get_component('light.test')
platform.init() platform.init()
self.assertTrue( self.assertTrue(
light.setup(self.hass, {light.DOMAIN: {CONF_PLATFORM: 'test'}})) setup_component(self.hass, light.DOMAIN,
{light.DOMAIN: {CONF_PLATFORM: 'test'}}))
dev1, dev2, dev3 = platform.DEVICES dev1, dev2, dev3 = platform.DEVICES
light.turn_on(self.hass, entity_id=dev2.entity_id) light.turn_on(self.hass, entity_id=dev2.entity_id)
@ -486,7 +495,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test') platform = loader.get_component('light.test')
platform.init() platform.init()
self.assertTrue( self.assertTrue(
light.setup(self.hass, {light.DOMAIN: {CONF_PLATFORM: 'test'}})) setup_component(self.hass, light.DOMAIN,
{light.DOMAIN: {CONF_PLATFORM: 'test'}}))
dev1 = platform.DEVICES[0] dev1 = platform.DEVICES[0]
@ -528,7 +538,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test') platform = loader.get_component('light.test')
platform.init() platform.init()
self.assertTrue( self.assertTrue(
light.setup(self.hass, {light.DOMAIN: {CONF_PLATFORM: 'test'}})) setup_component(self.hass, light.DOMAIN,
{light.DOMAIN: {CONF_PLATFORM: 'test'}}))
dev1 = platform.DEVICES[0] dev1 = platform.DEVICES[0]

View file

@ -2,6 +2,7 @@
# pylint: disable=too-many-public-methods,protected-access # pylint: disable=too-many-public-methods,protected-access
import unittest import unittest
from homeassistant.bootstrap import setup_component
from homeassistant import loader from homeassistant import loader
from homeassistant.components import switch from homeassistant.components import switch
from homeassistant.const import STATE_ON, STATE_OFF, CONF_PLATFORM from homeassistant.const import STATE_ON, STATE_OFF, CONF_PLATFORM
@ -17,10 +18,6 @@ class TestSwitch(unittest.TestCase):
self.hass = get_test_home_assistant() self.hass = get_test_home_assistant()
platform = loader.get_component('switch.test') platform = loader.get_component('switch.test')
platform.init() platform.init()
self.assertTrue(switch.setup(
self.hass, {switch.DOMAIN: {CONF_PLATFORM: 'test'}}
))
# Switch 1 is ON, switch 2 is OFF # Switch 1 is ON, switch 2 is OFF
self.switch_1, self.switch_2, self.switch_3 = \ self.switch_1, self.switch_2, self.switch_3 = \
platform.DEVICES platform.DEVICES
@ -31,6 +28,9 @@ class TestSwitch(unittest.TestCase):
def test_methods(self): def test_methods(self):
"""Test is_on, turn_on, turn_off methods.""" """Test is_on, turn_on, turn_off methods."""
self.assertTrue(setup_component(
self.hass, switch.DOMAIN, {switch.DOMAIN: {CONF_PLATFORM: 'test'}}
))
self.assertTrue(switch.is_on(self.hass)) self.assertTrue(switch.is_on(self.hass))
self.assertEqual( self.assertEqual(
STATE_ON, STATE_ON,
@ -83,8 +83,8 @@ class TestSwitch(unittest.TestCase):
loader.set_component('switch.test2', test_platform) loader.set_component('switch.test2', test_platform)
test_platform.init(False) test_platform.init(False)
self.assertTrue(switch.setup( self.assertTrue(setup_component(
self.hass, { self.hass, switch.DOMAIN, {
switch.DOMAIN: {CONF_PLATFORM: 'test'}, switch.DOMAIN: {CONF_PLATFORM: 'test'},
'{} 2'.format(switch.DOMAIN): {CONF_PLATFORM: 'test2'}, '{} 2'.format(switch.DOMAIN): {CONF_PLATFORM: 'test2'},
} }

View file

@ -1,6 +1,7 @@
"""The tests for the Scene component.""" """The tests for the Scene component."""
import unittest import unittest
from homeassistant.bootstrap import setup_component
from homeassistant import loader from homeassistant import loader
from homeassistant.components import light, scene from homeassistant.components import light, scene
@ -38,7 +39,7 @@ class TestScene(unittest.TestCase):
test_light = loader.get_component('light.test') test_light = loader.get_component('light.test')
test_light.init() test_light.init()
self.assertTrue(light.setup(self.hass, { self.assertTrue(setup_component(self.hass, light.DOMAIN, {
light.DOMAIN: {'platform': 'test'} light.DOMAIN: {'platform': 'test'}
})) }))
@ -52,7 +53,7 @@ class TestScene(unittest.TestCase):
'state': 'on', 'state': 'on',
'brightness': 100, 'brightness': 100,
} }
self.assertTrue(scene.setup(self.hass, { self.assertTrue(setup_component(self.hass, scene.DOMAIN, {
'scene': [{ 'scene': [{
'name': 'test', 'name': 'test',
'entities': { 'entities': {
@ -77,7 +78,7 @@ class TestScene(unittest.TestCase):
test_light = loader.get_component('light.test') test_light = loader.get_component('light.test')
test_light.init() test_light.init()
self.assertTrue(light.setup(self.hass, { self.assertTrue(setup_component(self.hass, light.DOMAIN, {
light.DOMAIN: {'platform': 'test'} light.DOMAIN: {'platform': 'test'}
})) }))
@ -87,7 +88,7 @@ class TestScene(unittest.TestCase):
self.hass.block_till_done() self.hass.block_till_done()
self.assertTrue(scene.setup(self.hass, { self.assertTrue(setup_component(self.hass, scene.DOMAIN, {
'scene': [{ 'scene': [{
'name': 'test', 'name': 'test',
'entities': { 'entities': {