async def test_preprocess_multiple_load_events(
    app_module_mock, token, mocker: MockerFixture
):
    """Test that a state hydrate event for multiple on-load events is processed correctly.

    Args:
        app_module_mock: The app module that will be returned by get_app().
        token: A token.
        mocker: pytest mock object.
    """
    mocker.patch(
        "reflex.state.State.class_subclasses", {OnLoadState, OnLoadInternalState}
    )
    app = app_module_mock.app = App(
        _state=State,
        _load_events={"index": [OnLoadState.test_handler, OnLoadState.test_handler]},
    )
    async with app.state_manager.modify_state(_substate_key(token, State)) as state:
        state.router_data = {"simulate": "hydrate"}

    updates = []
    async for update in rx.app.process(
        app=app,
        event=Event(
            token=token,
            name=f"{state.get_full_name()}.{CompileVars.ON_LOAD_INTERNAL}",
            router_data={RouteVar.PATH: "/", RouteVar.ORIGIN: "/", RouteVar.QUERY: {}},
        ),
        sid="sid",
        headers={},
        client_ip="",
    ):
        assert isinstance(update, StateUpdate)
        updates.append(update)
    assert len(updates) == 1
    assert updates[0].delta[State.get_name()].pop("router") is not None
    assert updates[0].delta == exp_is_hydrated(state, False)

    events = updates[0].events
    assert len(events) == 3
    async for update in state._process(events[0]):
        assert update.delta == {OnLoadState.get_full_name(): {"num": 1}}
    async for update in state._process(events[1]):
        assert update.delta == {OnLoadState.get_full_name(): {"num": 2}}
    async for update in state._process(events[2]):
        assert update.delta == exp_is_hydrated(state)

    if isinstance(app.state_manager, StateManagerRedis):
        await app.state_manager.close()
Test that a state hydrate event for multiple on-load events is processed correctly.

    Args:
        app_module_mock: The app module that will be returned by get_app().
        token: A token.
        mocker: pytest mock object.
    
tests/units/test_state.py