Fix to make tests work on Travis CI

This commit is contained in:
Paulus Schoutsen 2014-11-25 00:28:14 -08:00
parent 5cbe7bf1b8
commit 100948eb38
3 changed files with 10 additions and 9 deletions

View File

@ -12,7 +12,7 @@ import homeassistant.loader as loader
import homeassistant.components as components
import homeassistant.components.switch as switch
from mock import switch_platform
import mock_switch_platform
class TestSwitch(unittest.TestCase):
@ -21,14 +21,15 @@ class TestSwitch(unittest.TestCase):
def setUp(self): # pylint: disable=invalid-name
self.hass = ha.HomeAssistant()
loader.prepare(self.hass)
loader.set_component('switch.test', switch_platform)
loader.set_component('switch.test', mock_switch_platform)
self.assertTrue(switch.setup(
self.hass, {switch.DOMAIN: {ha.CONF_TYPE: 'test'}}
))
# 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
""" Stop down stuff we started. """
@ -88,12 +89,12 @@ class TestSwitch(unittest.TestCase):
))
# 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.hass, {switch.DOMAIN: {ha.CONF_TYPE: 'test'}}
))
switch_platform.fake_no_switches(False)
mock_switch_platform.fake_no_switches(False)

View File

@ -11,7 +11,7 @@ import homeassistant as ha
import homeassistant.loader as loader
import homeassistant.components.http as http
from mock import switch_platform
import mock_switch_platform
class TestLoader(unittest.TestCase):
@ -26,10 +26,10 @@ class TestLoader(unittest.TestCase):
def test_set_component(self):
""" Test if set_component works. """
loader.set_component('switch.test', switch_platform)
loader.set_component('switch.test', mock_switch_platform)
self.assertEqual(
switch_platform, loader.get_component('switch.test'))
mock_switch_platform, loader.get_component('switch.test'))
def test_get_component(self):
""" Test if get_component works. """