File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """Simple test for decentralized event handlers."""
2+
3+ import reflex as rx
4+
5+
6+ class TestState (rx .State ):
7+ """Test state class for decentralized event handlers."""
8+
9+ count : int = 0
10+
11+
12+ @rx .event
13+ def reset_count (state : TestState ):
14+ """Reset the count to zero.
15+
16+ Args:
17+ state: The test state to modify.
18+ """
19+ state .count = 0
20+
21+
22+ @rx .event
23+ def set_count (state : TestState , value : str ):
24+ """Set the count to a specific value.
25+
26+ Args:
27+ state: The test state to modify.
28+ value: The value to set as count.
29+ """
30+ state .count = int (value )
31+
32+
33+ def test_is_decentralized ():
34+ """Test if functions are correctly identified as decentralized event handlers."""
35+ from reflex .event import is_decentralized_event_handler , wrap_decentralized_handler
36+
37+ assert is_decentralized_event_handler (reset_count )
38+
39+ wrapped = wrap_decentralized_handler (reset_count )
40+ assert is_decentralized_event_handler (wrapped )
41+
42+ assert is_decentralized_event_handler (set_count )
43+ wrapped_with_params = wrap_decentralized_handler (set_count )
44+ assert is_decentralized_event_handler (wrapped_with_params )
45+
46+
47+ if __name__ == "__main__" :
48+ test_is_decentralized ()
You can’t perform that action at this time.
0 commit comments