Repository: home-assistant/core
File: tests/components/switchbot/test_cover.py (Python)

Code before:
            SERVICE_SET_COVER_POSITION,
            {ATTR_ENTITY_ID: entity_id, ATTR_POSITION: 50},
            blocking=True,
        )
        inject_bluetooth_service_info(
            hass, make_advertisement(address, manufacturer_data, service_data)
        )
        await hass.async_block_till_done()

        mock_set_position.assert_awaited_once()
        state = hass.states.get(entity_id)
        assert state.state == CoverState.OPEN
        assert state.attributes[ATTR_CURRENT_POSITION] == 60


async def test_curtain3_slow_mode_controlling(
    hass: HomeAssistant, mock_entry_factory: Callable[[str], MockConfigEntry]
) -> None:
    """Test Curtain3 controlling when slow mode is enabled."""
    inject_bluetooth_service_info(hass, WOCURTAIN3_SERVICE_INFO)

    entry = mock_entry_factory(sensor_type="curtain")
    entry.options = {
        CONF_RETRY_COUNT: DEFAULT_RETRY_COUNT,
        CONF_CURTAIN_SLOW_MODE: True,
    }
    entry.add_to_hass(hass)

    with (
        patch(
            "homeassistant.components.switchbot.cover.switchbot.SwitchbotCurtain.open",
            new=AsyncMock(return_value=True),
        ) as mock_open,
        patch(
            "homeassistant.components.switchbot.cover.switchbot.SwitchbotCurtain.close",
            new=AsyncMock(return_value=True),
        ) as mock_close,
    ):
        assert await hass.config_entries.async_setup(entry.entry_id)
        await hass.async_block_till_done()

        entity_id = "cover.test_name"

        await hass.services.async_call(
            COVER_DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: entity_id}, blocking=True
        )
        await hass.async_block_till_done()
        mock_open.assert_awaited_once_with(CURTAIN_SPEED_SLOW)

        await hass.services.async_call(
            COVER_DOMAIN,

Review comment (bug):
Could you please update this part to use `await hass.config_entries.async_update_entry(…)` instead in order to fix [the failing test](https://github.com/home-assistant/core/actions/runs/18845154844/job/53768327549?pr=155272)?

Code after:
            blocking=True,
        )
        inject_bluetooth_service_info(
            hass, make_advertisement(address, manufacturer_data, service_data)
        )
        await hass.async_block_till_done()

        mock_set_position.assert_awaited_once()
        state = hass.states.get(entity_id)
        assert state.state == CoverState.OPEN
        assert state.attributes[ATTR_CURRENT_POSITION] == 60


async def test_curtain3_custom_speed_controlling(
    hass: HomeAssistant, mock_entry_factory: Callable[[str], MockConfigEntry]
) -> None:
    """Test Curtain3 controlling with custom speed."""
    inject_bluetooth_service_info(hass, WOCURTAIN3_SERVICE_INFO)

    entry = mock_entry_factory(sensor_type="curtain")
    entry.add_to_hass(hass)

    # Update entry options using async_update_entry
    hass.config_entries.async_update_entry(
        entry,
        options={
            CONF_RETRY_COUNT: DEFAULT_RETRY_COUNT,
            CONF_CURTAIN_SPEED: 50,
        },
    )

    with (
        patch(
            "homeassistant.components.switchbot.cover.switchbot.SwitchbotCurtain.open",
            new=AsyncMock(return_value=True),
        ) as mock_open,
        patch(
            "homeassistant.components.switchbot.cover.switchbot.SwitchbotCurtain.close",
            new=AsyncMock(return_value=True),
        ) as mock_close,
    ):
        assert await hass.config_entries.async_setup(entry.entry_id)
        await hass.async_block_till_done()

        entity_id = "cover.test_name"

        await hass.services.async_call(
            COVER_DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: entity_id}, blocking=True
        )
        await hass.async_block_till_done()
        mock_open.assert_awaited_once_with(50)