async def test_cancellable_service_calls_task(hass):
    """Test the creation and execution of the task that wraps adaptation service calls."""
    (light, *_) = await setup_lights(hass)
    _, switch = await setup_switch(hass, {CONF_SEPARATE_TURN_ON_COMMANDS: True})
    context = switch.create_context("test")

    assert switch.manager.adaptation_tasks_color.get(light.entity_id) is None

    service_data = {
        ATTR_BRIGHTNESS: 10,
        ATTR_COLOR_TEMP_KELVIN: 10,
        ATTR_ENTITY_ID: light.entity_id,
    }
    adaptation_data = AdaptationData(
        light.entity_id,
        context,
        0,
        _create_service_call_data_iterator(hass, [service_data], False),
        force=False,
        max_length=1,
        which="both",
    )
    await switch.execute_cancellable_adaptation_calls(adaptation_data)

    task = switch.manager.adaptation_tasks_brightness.get(light.entity_id)
    task2 = switch.manager.adaptation_tasks_color.get(light.entity_id)
    assert task is task2
    assert task is not None
    assert task.done()
Test the creation and execution of the task that wraps adaptation service calls.
tests/test_switch.py