Merge remote-tracking branch 'balloob/dev' into automation-decorator

# Conflicts:
#	homeassistant/helpers/service.py
#	tests/helpers/test_service.py
This commit is contained in:
Ryan Kraus 2016-01-24 22:51:00 -05:00
commit 60dd2d441d
28 changed files with 374 additions and 191 deletions

View file

@ -7,6 +7,8 @@ Test service helpers.
import unittest
from unittest.mock import patch
from homeassistant import core as ha, loader
from homeassistant.const import STATE_ON, STATE_OFF, ATTR_ENTITY_ID
from homeassistant.helpers import service
from tests.common import get_test_home_assistant, mock_service
@ -78,3 +80,24 @@ class TestServiceHelpers(unittest.TestCase):
'service': 'invalid'
})
self.assertEqual(3, mock_log.call_count)
def test_extract_entity_ids(self):
""" Test extract_entity_ids method. """
self.hass.states.set('light.Bowl', STATE_ON)
self.hass.states.set('light.Ceiling', STATE_OFF)
self.hass.states.set('light.Kitchen', STATE_OFF)
loader.get_component('group').setup_group(
self.hass, 'test', ['light.Ceiling', 'light.Kitchen'])
call = ha.ServiceCall('light', 'turn_on',
{ATTR_ENTITY_ID: 'light.Bowl'})
self.assertEqual(['light.bowl'],
service.extract_entity_ids(self.hass, call))
call = ha.ServiceCall('light', 'turn_on',
{ATTR_ENTITY_ID: 'group.test'})
self.assertEqual(['light.ceiling', 'light.kitchen'],
service.extract_entity_ids(self.hass, call))