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

Function test_get_substate

tests/units/test_state.py:691–716  ·  view source on GitHub ↗

Test getting the substate of a state. Args: test_state: A state. child_state: A child state. child_state2: A child state. grandchild_state: A grandchild state.

(test_state, child_state, child_state2, grandchild_state)

Source from the content-addressed store, hash-verified

689
690
691def test_get_substate(test_state, child_state, child_state2, grandchild_state):
692 """Test getting the substate of a state.
693
694 Args:
695 test_state: A state.
696 child_state: A child state.
697 child_state2: A child state.
698 grandchild_state: A grandchild state.
699 """
700 assert test_state.get_substate((ChildState.get_name(),)) == child_state
701 assert test_state.get_substate((ChildState2.get_name(),)) == child_state2
702 assert (
703 test_state.get_substate((ChildState.get_name(), GrandchildState.get_name()))
704 == grandchild_state
705 )
706 assert child_state.get_substate((GrandchildState.get_name(),)) == grandchild_state
707 with pytest.raises(ValueError):
708 test_state.get_substate(("invalid",))
709 with pytest.raises(ValueError):
710 test_state.get_substate((ChildState.get_name(), "invalid"))
711 with pytest.raises(ValueError):
712 test_state.get_substate((
713 ChildState.get_name(),
714 GrandchildState.get_name(),
715 "invalid",
716 ))
717
718
719def test_set_dirty_var(test_state):

Callers

nothing calls this directly

Calls 2

get_nameMethod · 0.80
get_substateMethod · 0.45

Tested by

no test coverage detected