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

+4 -3
View File
@@ -4,6 +4,7 @@ import unittest.mock as mock
import requests
from homeassistant.bootstrap import setup_component
import homeassistant.components.sensor as sensor
import homeassistant.components.sensor.mfi as mfi
from homeassistant.const import TEMP_CELSIUS
@@ -69,7 +70,7 @@ class TestMfiSensorSetup(unittest.TestCase):
"""Test setup with minimum configuration."""
config = dict(self.GOOD_CONFIG)
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(
'foo', 'user', 'pass', port=6443, use_tls=True, verify=True)
@@ -78,7 +79,7 @@ class TestMfiSensorSetup(unittest.TestCase):
"""Test setup with port."""
config = dict(self.GOOD_CONFIG)
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(
'foo', 'user', 'pass', port=6123, use_tls=True, verify=True)
@@ -89,7 +90,7 @@ class TestMfiSensorSetup(unittest.TestCase):
del config[self.THING]['port']
config[self.THING]['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(
'foo', 'user', 'pass', port=6080, use_tls=False, verify=False)
@@ -1,6 +1,7 @@
"""The tests for the MoldIndicator sensor."""
import unittest
from homeassistant.bootstrap import setup_component
import homeassistant.components.sensor as sensor
from homeassistant.components.sensor.mold_indicator import (ATTR_DEWPOINT,
ATTR_CRITICAL_TEMP)
@@ -22,7 +23,6 @@ class TestSensorMoldIndicator(unittest.TestCase):
{ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS})
self.hass.states.set('test.indoorhumidity', '50',
{ATTR_UNIT_OF_MEASUREMENT: '%'})
self.hass.block_till_done()
def tearDown(self):
"""Stop down everything that was started."""
@@ -30,7 +30,7 @@ class TestSensorMoldIndicator(unittest.TestCase):
def test_setup(self):
"""Test the mold indicator sensor setup."""
self.assertTrue(sensor.setup(self.hass, {
self.assertTrue(setup_component(self.hass, sensor.DOMAIN, {
'sensor': {
'platform': 'mold_indicator',
'indoor_temp_sensor': 'test.indoortemp',
@@ -53,7 +53,7 @@ class TestSensorMoldIndicator(unittest.TestCase):
self.hass.states.set('test.indoorhumidity', '0',
{ATTR_UNIT_OF_MEASUREMENT: '%'})
self.assertTrue(sensor.setup(self.hass, {
self.assertTrue(setup_component(self.hass, sensor.DOMAIN, {
'sensor': {
'platform': 'mold_indicator',
'indoor_temp_sensor': 'test.indoortemp',
@@ -68,7 +68,7 @@ class TestSensorMoldIndicator(unittest.TestCase):
def test_calculation(self):
"""Test the mold indicator internal calculations."""
self.assertTrue(sensor.setup(self.hass, {
self.assertTrue(setup_component(self.hass, sensor.DOMAIN, {
'sensor': {
'platform': 'mold_indicator',
'indoor_temp_sensor': 'test.indoortemp',
@@ -100,7 +100,7 @@ class TestSensorMoldIndicator(unittest.TestCase):
def test_sensor_changed(self):
"""Test the sensor_changed function."""
self.assertTrue(sensor.setup(self.hass, {
self.assertTrue(setup_component(self.hass, sensor.DOMAIN, {
'sensor': {
'platform': 'mold_indicator',
'indoor_temp_sensor': 'test.indoortemp',
+2 -1
View File
@@ -4,6 +4,7 @@ import datetime
import unittest
from unittest.mock import patch
from homeassistant.bootstrap import setup_component
import homeassistant.components.sensor as sensor
from homeassistant.components.mqtt import (CONF_STATE_TOPIC, CONF_QOS,
DEFAULT_QOS)
@@ -52,7 +53,7 @@ class TestMQTTRoomSensor(unittest.TestCase):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
mock_mqtt_component(self.hass)
self.assertTrue(sensor.setup(self.hass, {
self.assertTrue(setup_component(self.hass, sensor.DOMAIN, {
sensor.DOMAIN: {
CONF_PLATFORM: 'mqtt_room',
CONF_NAME: NAME,