Tracking all groups to allow changing of existing groups (#11444)
* Tracking all groups to allow changing of existing groups * Unit tests * Fix flake8 warnings in test
This commit is contained in:
1 parent
6cc285aea5
commit
60ce2b343d
2 files changed
+36
-6
No files matched your search
@@ -8,7 +8,7 @@ from unittest.mock import patch
|
||||
from homeassistant.setup import setup_component, async_setup_component
|
||||
from homeassistant.const import (
|
||||
STATE_ON, STATE_OFF, STATE_HOME, STATE_UNKNOWN, ATTR_ICON, ATTR_HIDDEN,
|
||||
ATTR_ASSUMED_STATE, STATE_NOT_HOME)
|
||||
ATTR_ASSUMED_STATE, STATE_NOT_HOME, ATTR_FRIENDLY_NAME)
|
||||
import homeassistant.components.group as group
|
||||
|
||||
from tests.common import get_test_home_assistant, assert_setup_component
|
||||
@@ -395,6 +395,29 @@ class TestComponentsGroup(unittest.TestCase):
|
||||
group_state = self.hass.states.get(group_entity_id)
|
||||
self.assertIsNone(group_state.attributes.get(ATTR_HIDDEN))
|
||||
|
||||
def test_modify_group(self):
|
||||
"""Test modifying a group."""
|
||||
group_conf = OrderedDict()
|
||||
group_conf['modify_group'] = {
|
||||
'name': 'friendly_name',
|
||||
'icon': 'mdi:work'
|
||||
}
|
||||
|
||||
assert setup_component(self.hass, 'group', {'group': group_conf})
|
||||
|
||||
# The old way would create a new group modify_group1 because
|
||||
# internally it didn't know anything about those created in the config
|
||||
group.set_group(self.hass, 'modify_group', icon="mdi:play")
|
||||
self.hass.block_till_done()
|
||||
|
||||
group_state = self.hass.states.get(
|
||||
group.ENTITY_ID_FORMAT.format('modify_group'))
|
||||
|
||||
assert self.hass.states.entity_ids() == ['group.modify_group']
|
||||
assert group_state.attributes.get(ATTR_ICON) == 'mdi:play'
|
||||
assert group_state.attributes.get(ATTR_FRIENDLY_NAME) == \
|
||||
'friendly_name'
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_service_group_services(hass):
|
||||
|
||||
Reference in new issue
Block a user