async def test_create_service_call_data_iterator(
    service_datas: list[ServiceData],
    filter_by_state: bool,
    service_datas_expected: list[ServiceData],
    hass_states_mock,
):
    """Test the generator function for correct enumeration and filtering."""
    generated_service_datas = [
        data
        async for data in _create_service_call_data_iterator(
            hass_states_mock,
            service_datas,
            filter_by_state,
        )
    ]

    assert generated_service_datas == service_datas_expected
    assert (
        hass_states_mock.states.get.call_count == 0
        if not filter_by_state
        else len(service_datas)
    )
Test the generator function for correct enumeration and filtering.
tests/test_adaptation_utils.py