From 845a028d427973461dd2754f5b553a03d5bc1448 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 25 Nov 2014 19:16:42 -0800 Subject: [PATCH] Renamed mock_switch_platform to mock_toggledevice_platform --- ...tform.py => mock_toggledevice_platform.py} | 24 ++++++++++--------- test/test_component_switch.py | 19 ++++++++------- test/test_loader.py | 6 ++--- 3 files changed, 26 insertions(+), 23 deletions(-) rename test/{mock_switch_platform.py => mock_toggledevice_platform.py} (65%) diff --git a/test/mock_switch_platform.py b/test/mock_toggledevice_platform.py similarity index 65% rename from test/mock_switch_platform.py rename to test/mock_toggledevice_platform.py index fa92912348f..6488e8f8b9c 100644 --- a/test/mock_switch_platform.py +++ b/test/mock_toggledevice_platform.py @@ -7,7 +7,7 @@ Provides a mock switch platform. import homeassistant.components as components -class MockSwitch(components.ToggleDevice): +class MockToggleDevice(components.ToggleDevice): """ Fake switch. """ def __init__(self, name, state): self.name = name @@ -34,22 +34,24 @@ class MockSwitch(components.ToggleDevice): return {} -FAKE_NO_SWITCHES = False +FAKE_NO_DEVICES = False -SWITCHES = [ - MockSwitch('AC', components.STATE_ON), - MockSwitch('AC', components.STATE_OFF), - MockSwitch(None, components.STATE_OFF) +DEVICES = [ + MockToggleDevice('AC', components.STATE_ON), + MockToggleDevice('AC', components.STATE_OFF), + MockToggleDevice(None, components.STATE_OFF) ] def fake_no_switches(do_fake): - """ Set the platform to act as if it has no switches. """ - global FAKE_NO_SWITCHES + """ Set the platform to act as if it has no devices. """ + global FAKE_NO_DEVICES - FAKE_NO_SWITCHES = do_fake + FAKE_NO_DEVICES = do_fake def get_switches(hass, config): - """ Returns mock switches. """ - return [] if FAKE_NO_SWITCHES else SWITCHES + """ Returns mock devices. """ + return [] if FAKE_NO_DEVICES else DEVICES + +get_lights = get_switches diff --git a/test/test_component_switch.py b/test/test_component_switch.py index 1e8e9dab3eb..6432369e7ed 100644 --- a/test/test_component_switch.py +++ b/test/test_component_switch.py @@ -1,8 +1,8 @@ """ -test.test_component_chromecast -~~~~~~~~~~~ +test.test_component_switch +~~~~~~~~~~~~~~~~~~~~~~~~~~ -Tests Chromecast component. +Tests switch component. """ # pylint: disable=too-many-public-methods,protected-access import unittest @@ -12,7 +12,7 @@ import homeassistant.loader as loader import homeassistant.components as components import homeassistant.components.switch as switch -import mock_switch_platform +import mock_toggledevice_platform class TestSwitch(unittest.TestCase): @@ -21,7 +21,7 @@ class TestSwitch(unittest.TestCase): def setUp(self): # pylint: disable=invalid-name self.hass = ha.HomeAssistant() loader.prepare(self.hass) - loader.set_component('switch.test', mock_switch_platform) + loader.set_component('switch.test', mock_toggledevice_platform) self.assertTrue(switch.setup( self.hass, {switch.DOMAIN: {ha.CONF_TYPE: 'test'}} @@ -29,7 +29,7 @@ class TestSwitch(unittest.TestCase): # Switch 1 is ON, switch 2 is OFF self.switch_1, self.switch_2, self.switch_3 = \ - mock_switch_platform.get_switches(None, None) + mock_toggledevice_platform.get_switches(None, None) def tearDown(self): # pylint: disable=invalid-name """ Stop down stuff we started. """ @@ -92,12 +92,13 @@ class TestSwitch(unittest.TestCase): )) # Test if switch component returns 0 switches - mock_switch_platform.fake_no_switches(True) + mock_toggledevice_platform.fake_no_switches(True) - self.assertEqual([], mock_switch_platform.get_switches(None, None)) + self.assertEqual( + [], mock_toggledevice_platform.get_switches(None, None)) self.assertFalse(switch.setup( self.hass, {switch.DOMAIN: {ha.CONF_TYPE: 'test'}} )) - mock_switch_platform.fake_no_switches(False) + mock_toggledevice_platform.fake_no_switches(False) diff --git a/test/test_loader.py b/test/test_loader.py index 3df83292df9..be0adbff621 100644 --- a/test/test_loader.py +++ b/test/test_loader.py @@ -11,7 +11,7 @@ import homeassistant as ha import homeassistant.loader as loader import homeassistant.components.http as http -import mock_switch_platform +import mock_toggledevice_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', mock_switch_platform) + loader.set_component('switch.test', mock_toggledevice_platform) self.assertEqual( - mock_switch_platform, loader.get_component('switch.test')) + mock_toggledevice_platform, loader.get_component('switch.test')) def test_get_component(self): """ Test if get_component works. """