async def test_expand_entity_ids_does_not_return_duplicates(opp): """Test that expand_entity_ids does not return duplicates.""" opp.states.async_set("light.Bowl", STATE_ON) opp.states.async_set("light.Ceiling", STATE_OFF) assert await async_setup_component(opp, "group", {}) test_group = await group.Group.async_create_group( opp, "init_group", ["light.Bowl", "light.Ceiling"], False) assert ["light.bowl", "light.ceiling"] == sorted( group.expand_entity_ids(opp, [test_group.entity_id, "light.Ceiling"])) assert ["light.bowl", "light.ceiling"] == sorted( group.expand_entity_ids(opp, ["light.bowl", test_group.entity_id]))
async def test_expand_entity_ids(opp): """Test expand_entity_ids method.""" opp.states.async_set("light.Bowl", STATE_ON) opp.states.async_set("light.Ceiling", STATE_OFF) assert await async_setup_component(opp, "group", {}) test_group = await group.Group.async_create_group( opp, "init_group", ["light.Bowl", "light.Ceiling"], False) assert sorted(["light.ceiling", "light.bowl"]) == sorted( group.expand_entity_ids(opp, [test_group.entity_id]))
async def test_expand_entity_ids_expands_nested_groups(opp): """Test if entity ids epands to nested groups.""" assert await async_setup_component(opp, "group", {}) await group.Group.async_create_group(opp, "light", ["light.test_1", "light.test_2"]) await group.Group.async_create_group(opp, "switch", ["switch.test_1", "switch.test_2"]) await group.Group.async_create_group(opp, "group_of_groups", ["group.light", "group.switch"]) assert [ "light.test_1", "light.test_2", "switch.test_1", "switch.test_2", ] == sorted(group.expand_entity_ids(opp, ["group.group_of_groups"]))
async def test_expand_entity_ids_ignores_non_strings(opp): """Test that non string elements in lists are ignored.""" assert [] == group.expand_entity_ids(opp, [5, True])