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

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

View file

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

View file

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

View file

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