mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Fix to make tests work on Travis CI
This commit is contained in:
parent
5cbe7bf1b8
commit
100948eb38
@ -12,7 +12,7 @@ import homeassistant.loader as loader
|
|||||||
import homeassistant.components as components
|
import homeassistant.components as components
|
||||||
import homeassistant.components.switch as switch
|
import homeassistant.components.switch as switch
|
||||||
|
|
||||||
from mock import switch_platform
|
import mock_switch_platform
|
||||||
|
|
||||||
|
|
||||||
class TestSwitch(unittest.TestCase):
|
class TestSwitch(unittest.TestCase):
|
||||||
@ -21,14 +21,15 @@ class TestSwitch(unittest.TestCase):
|
|||||||
def setUp(self): # pylint: disable=invalid-name
|
def setUp(self): # pylint: disable=invalid-name
|
||||||
self.hass = ha.HomeAssistant()
|
self.hass = ha.HomeAssistant()
|
||||||
loader.prepare(self.hass)
|
loader.prepare(self.hass)
|
||||||
loader.set_component('switch.test', switch_platform)
|
loader.set_component('switch.test', mock_switch_platform)
|
||||||
|
|
||||||
self.assertTrue(switch.setup(
|
self.assertTrue(switch.setup(
|
||||||
self.hass, {switch.DOMAIN: {ha.CONF_TYPE: 'test'}}
|
self.hass, {switch.DOMAIN: {ha.CONF_TYPE: 'test'}}
|
||||||
))
|
))
|
||||||
|
|
||||||
# Switch 1 is ON, switch 2 is OFF
|
# Switch 1 is ON, switch 2 is OFF
|
||||||
self.switch_1, self.switch_2 = switch_platform.get_switches(None, None)
|
self.switch_1, self.switch_2 = \
|
||||||
|
mock_switch_platform.get_switches(None, None)
|
||||||
|
|
||||||
def tearDown(self): # pylint: disable=invalid-name
|
def tearDown(self): # pylint: disable=invalid-name
|
||||||
""" Stop down stuff we started. """
|
""" Stop down stuff we started. """
|
||||||
@ -88,12 +89,12 @@ class TestSwitch(unittest.TestCase):
|
|||||||
))
|
))
|
||||||
|
|
||||||
# Test if switch component returns 0 switches
|
# Test if switch component returns 0 switches
|
||||||
switch_platform.fake_no_switches(True)
|
mock_switch_platform.fake_no_switches(True)
|
||||||
|
|
||||||
self.assertEqual([], switch_platform.get_switches(None, None))
|
self.assertEqual([], mock_switch_platform.get_switches(None, None))
|
||||||
|
|
||||||
self.assertFalse(switch.setup(
|
self.assertFalse(switch.setup(
|
||||||
self.hass, {switch.DOMAIN: {ha.CONF_TYPE: 'test'}}
|
self.hass, {switch.DOMAIN: {ha.CONF_TYPE: 'test'}}
|
||||||
))
|
))
|
||||||
|
|
||||||
switch_platform.fake_no_switches(False)
|
mock_switch_platform.fake_no_switches(False)
|
||||||
|
@ -11,7 +11,7 @@ import homeassistant as ha
|
|||||||
import homeassistant.loader as loader
|
import homeassistant.loader as loader
|
||||||
import homeassistant.components.http as http
|
import homeassistant.components.http as http
|
||||||
|
|
||||||
from mock import switch_platform
|
import mock_switch_platform
|
||||||
|
|
||||||
|
|
||||||
class TestLoader(unittest.TestCase):
|
class TestLoader(unittest.TestCase):
|
||||||
@ -26,10 +26,10 @@ class TestLoader(unittest.TestCase):
|
|||||||
|
|
||||||
def test_set_component(self):
|
def test_set_component(self):
|
||||||
""" Test if set_component works. """
|
""" Test if set_component works. """
|
||||||
loader.set_component('switch.test', switch_platform)
|
loader.set_component('switch.test', mock_switch_platform)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
switch_platform, loader.get_component('switch.test'))
|
mock_switch_platform, loader.get_component('switch.test'))
|
||||||
|
|
||||||
def test_get_component(self):
|
def test_get_component(self):
|
||||||
""" Test if get_component works. """
|
""" Test if get_component works. """
|
||||||
|
Loading…
x
Reference in New Issue
Block a user