Added tests for toggle service.

1) Added tests to toggle service.
2) Removed color_util import in light tests. It was not being used.
This commit is contained in:
Ryan Kraus committed 2016-01-17 16:42:18 -05:00
1 parent 342a819fd4
commit 0624445627
3 files changed
+53 -5

No files matched your search

+13 -1
View File
@@ -10,7 +10,7 @@ from unittest.mock import patch
import homeassistant.core as ha
from homeassistant.const import (
STATE_ON, STATE_OFF, SERVICE_TURN_ON, SERVICE_TURN_OFF)
STATE_ON, STATE_OFF, SERVICE_TURN_ON, SERVICE_TURN_OFF, SERVICE_TOGGLE)
import homeassistant.components as comps
from tests.common import get_test_home_assistant
@@ -61,6 +61,18 @@ class TestComponentsCore(unittest.TestCase):
self.assertEqual(1, len(runs))
def test_toggle(self):
""" Test toggle method. """
runs = []
self.hass.services.register(
'light', SERVICE_TOGGLE, lambda x: runs.append(1))
comps.toggle(self.hass, 'light.Bowl')
self.hass.pool.block_till_done()
self.assertEqual(1, len(runs))
@patch('homeassistant.core.ServiceRegistry.call')
def test_turn_on_to_not_block_for_domains_without_service(self, mock_call):
self.hass.services.register('light', SERVICE_TURN_ON, lambda x: x)