async def test_async_computed_var_get_state(mock_app: rx.App, token: str):
    """A test where an async computed var depends on a var in another state.

    Args:
        mock_app: An app that will be returned by `get_app()`
        token: A token.
    """

    class Parent(BaseState):
        """A root state like rx.State."""

        parent_var: int = 0

    class Child2(Parent):
        """An unconnected child state."""

    class Child3(Parent):
        """A child state with a computed var causing it to be pre-fetched.

        If child3_var gets set to a value, and `get_state` erroneously
        re-fetches it from redis, the value will be lost.
        """

        child3_var: int = 0

        @rx.var(cache=True)
        def v(self) -> int:
            return self.child3_var

    class Child(Parent):
        """A state simulating UpdateVarsInternalState."""

        @rx.var(cache=True)
        async def v(self) -> int:
            p = await self.get_state(Parent)
            child3 = await self.get_state(Child3)
            return child3.child3_var + p.parent_var

    mock_app.state_manager.state = mock_app._state = Parent

    # Get the top level state via unconnected sibling.
    root = await mock_app.state_manager.get_state(_substate_key(token, Child))
    # Set value in parent_var to assert it does not get refetched later.
    root.parent_var = 1

    if isinstance(mock_app.state_manager, StateManagerRedis):
        # When redis is used, only states with uncached computed vars are pre-fetched.
        assert Child2.get_name() not in root.substates
        assert Child3.get_name() not in root.substates

    # Get the unconnected sibling state, which will be used to `get_state` other instances.
    child = root.get_substate(Child.get_full_name().split("."))

    # Get an uncached child state.
    child2 = await child.get_state(Child2)
    assert child2.parent_var == 1

    # Set value on already-cached Child3 state (prefetched because it has a Computed Var).
    child3 = await child.get_state(Child3)
    child3.child3_var = 1

    assert await child.v == 2
    assert await child.v == 2
    root.parent_var = 2
    assert await child.v == 3
A test where an async computed var depends on a var in another state.

    Args:
        mock_app: An app that will be returned by `get_app()`
        token: A token.
    
tests/units/test_state.py