Beispiel #1
0
def test_service_group_set_group_remove_group(hass):
    """Check if service are available."""
    with assert_setup_component(0, 'group'):
        yield from async_setup_component(hass, 'group', {'group': {}})

    group.async_set_group(hass, 'user_test_group', name="Test")
    yield from hass.async_block_till_done()

    group_state = hass.states.get('group.user_test_group')
    assert group_state
    assert group_state.attributes[group.ATTR_AUTO]
    assert group_state.attributes['friendly_name'] == "Test"

    group.async_set_group(hass,
                          'user_test_group',
                          view=True,
                          visible=False,
                          entity_ids=['test.entity_bla1'])
    yield from hass.async_block_till_done()

    group_state = hass.states.get('group.user_test_group')
    assert group_state
    assert group_state.attributes[group.ATTR_VIEW]
    assert group_state.attributes[group.ATTR_AUTO]
    assert group_state.attributes['hidden']
    assert group_state.attributes['friendly_name'] == "Test"
    assert list(group_state.attributes['entity_id']) == ['test.entity_bla1']

    group.async_set_group(hass,
                          'user_test_group',
                          icon="mdi:camera",
                          name="Test2",
                          control="hidden",
                          add=['test.entity_id2'])
    yield from hass.async_block_till_done()

    group_state = hass.states.get('group.user_test_group')
    assert group_state
    assert group_state.attributes[group.ATTR_VIEW]
    assert group_state.attributes[group.ATTR_AUTO]
    assert group_state.attributes['hidden']
    assert group_state.attributes['friendly_name'] == "Test2"
    assert group_state.attributes['icon'] == "mdi:camera"
    assert group_state.attributes[group.ATTR_CONTROL] == "hidden"
    assert sorted(list(group_state.attributes['entity_id'])) == sorted(
        ['test.entity_bla1', 'test.entity_id2'])

    group.async_remove(hass, 'user_test_group')
    yield from hass.async_block_till_done()

    group_state = hass.states.get('group.user_test_group')
    assert group_state is None
def test_service_group_set_group_remove_group(hass):
    """Check if service are available."""
    with assert_setup_component(0, 'group'):
        yield from async_setup_component(hass, 'group', {
            'group': {}
        })

    group.async_set_group(hass, 'user_test_group', name="Test")
    yield from hass.async_block_till_done()

    group_state = hass.states.get('group.user_test_group')
    assert group_state
    assert group_state.attributes[group.ATTR_AUTO]
    assert group_state.attributes['friendly_name'] == "Test"

    group.async_set_group(
        hass, 'user_test_group', view=True, visible=False,
        entity_ids=['test.entity_bla1'])
    yield from hass.async_block_till_done()

    group_state = hass.states.get('group.user_test_group')
    assert group_state
    assert group_state.attributes[group.ATTR_VIEW]
    assert group_state.attributes[group.ATTR_AUTO]
    assert group_state.attributes['hidden']
    assert group_state.attributes['friendly_name'] == "Test"
    assert list(group_state.attributes['entity_id']) == ['test.entity_bla1']

    group.async_set_group(
        hass, 'user_test_group', icon="mdi:camera", name="Test2",
        control="hidden", add=['test.entity_id2'])
    yield from hass.async_block_till_done()

    group_state = hass.states.get('group.user_test_group')
    assert group_state
    assert group_state.attributes[group.ATTR_VIEW]
    assert group_state.attributes[group.ATTR_AUTO]
    assert group_state.attributes['hidden']
    assert group_state.attributes['friendly_name'] == "Test2"
    assert group_state.attributes['icon'] == "mdi:camera"
    assert group_state.attributes[group.ATTR_CONTROL] == "hidden"
    assert sorted(list(group_state.attributes['entity_id'])) == sorted([
        'test.entity_bla1', 'test.entity_id2'])

    group.async_remove(hass, 'user_test_group')
    yield from hass.async_block_till_done()

    group_state = hass.states.get('group.user_test_group')
    assert group_state is None