MCPcopy
hub / github.com/reflex-dev/reflex / test_get_state_tree

Function test_get_state_tree

tests/units/test_state_tree.py:360–386  ·  view source on GitHub ↗

Test getting state trees and assert on which branches are retrieved. Args: state_manager_redis: The state manager redis fixture. token: The token fixture. substate_cls: The substate class to retrieve. exp_root_substates: The expected substates of the root state.

(
    state_manager_redis,
    token,
    substate_cls,
    exp_root_substates,
    exp_root_dict_keys,
)

Source from the content-addressed store, hash-verified

358 ],
359)
360async def test_get_state_tree(
361 state_manager_redis,
362 token,
363 substate_cls,
364 exp_root_substates,
365 exp_root_dict_keys,
366):
367 """Test getting state trees and assert on which branches are retrieved.
368
369 Args:
370 state_manager_redis: The state manager redis fixture.
371 token: The token fixture.
372 substate_cls: The substate class to retrieve.
373 exp_root_substates: The expected substates of the root state.
374 exp_root_dict_keys: The expected keys of the root state dict.
375 """
376 state = await state_manager_redis.get_state(
377 BaseStateToken(ident=token, cls=substate_cls)
378 )
379 assert isinstance(state, Root)
380 assert sorted(state.substates) == sorted(exp_root_substates)
381
382 # Only computed vars should be returned
383 assert state.get_delta() == ALWAYS_COMPUTED_VARS
384
385 # All of TreeA, TreeD, and TreeE substates should be in the dict
386 assert sorted(state.dict()) == sorted(exp_root_dict_keys)

Callers

nothing calls this directly

Calls 4

BaseStateTokenClass · 0.90
get_deltaMethod · 0.80
get_stateMethod · 0.45
dictMethod · 0.45

Tested by

no test coverage detected