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 authored and GitHub committed 2016-09-17 10:29:58 -07:00
1 parent d7452f9d5d
commit 4076ccf639
29 files changed
+220 -141

No files matched your search

+27 -16
View File
@@ -3,7 +3,7 @@ import unittest
from datetime import timedelta
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.const import CONF_PLATFORM, STATE_ON, SERVICE_TURN_ON
import homeassistant.loader as loader
@@ -25,7 +25,7 @@ class TestSwitchFlux(unittest.TestCase):
def test_valid_config(self):
"""Test configuration."""
assert _setup_component(self.hass, 'switch', {
assert setup_component(self.hass, 'switch', {
'switch': {
'platform': 'flux',
'name': 'flux',
@@ -35,7 +35,7 @@ class TestSwitchFlux(unittest.TestCase):
def test_valid_config_with_info(self):
"""Test configuration."""
assert _setup_component(self.hass, 'switch', {
assert setup_component(self.hass, 'switch', {
'switch': {
'platform': 'flux',
'name': 'flux',
@@ -50,7 +50,7 @@ class TestSwitchFlux(unittest.TestCase):
def test_valid_config_no_name(self):
"""Test configuration."""
assert _setup_component(self.hass, 'switch', {
assert setup_component(self.hass, 'switch', {
'switch': {
'platform': 'flux',
'lights': ['light.desk', 'light.lamp']
@@ -59,7 +59,7 @@ class TestSwitchFlux(unittest.TestCase):
def test_invalid_config_no_lights(self):
"""Test configuration."""
assert not _setup_component(self.hass, 'switch', {
assert not setup_component(self.hass, 'switch', {
'switch': {
'platform': 'flux',
'name': 'flux'
@@ -71,7 +71,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test')
platform.init()
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]
@@ -110,7 +111,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test')
platform.init()
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]
@@ -154,7 +156,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test')
platform.init()
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]
@@ -198,7 +201,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test')
platform.init()
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]
@@ -242,7 +246,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test')
platform.init()
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]
@@ -286,7 +291,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test')
platform.init()
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]
@@ -332,7 +338,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test')
platform.init()
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]
@@ -378,7 +385,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test')
platform.init()
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]
@@ -422,7 +430,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test')
platform.init()
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
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.init()
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]
@@ -528,7 +538,8 @@ class TestSwitchFlux(unittest.TestCase):
platform = loader.get_component('light.test')
platform.init()
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]