33from statemachine .exceptions import InvalidDefinition
44
55from statemachine import State
6- from statemachine import StateMachine
6+ from statemachine import StateChart
77
88
99def test_assign_events_on_transitions ():
10- class TrafficLightMachine (StateMachine ):
10+ class TrafficLightMachine (StateChart ):
1111 "A traffic light machine"
1212
1313 green = State (initial = True )
@@ -34,7 +34,7 @@ def on_cycle(self, event_data, event: str):
3434
3535class TestExplicitEvent :
3636 def test_accept_event_instance (self ):
37- class StartMachine (StateMachine ):
37+ class StartMachine (StateChart ):
3838 created = State (initial = True )
3939 started = State (final = True )
4040
@@ -46,10 +46,10 @@ class StartMachine(StateMachine):
4646
4747 sm = StartMachine ()
4848 sm .send ("start" )
49- assert sm .current_state == sm . started
49+ assert sm .started . is_active
5050
5151 def test_accept_event_name (self ):
52- class StartMachine (StateMachine ):
52+ class StartMachine (StateChart ):
5353 created = State (initial = True )
5454 started = State (final = True )
5555
@@ -60,7 +60,7 @@ class StartMachine(StateMachine):
6060 assert StartMachine .start .name == "Start the machine"
6161
6262 def test_derive_name_from_id (self ):
63- class StartMachine (StateMachine ):
63+ class StartMachine (StateChart ):
6464 created = State (initial = True )
6565 started = State (final = True )
6666
@@ -74,7 +74,7 @@ class StartMachine(StateMachine):
7474 assert StartMachine .launch_the_machine == StartMachine .launch_the_machine .id
7575
7676 def test_not_derive_name_from_id_if_not_event_class (self ):
77- class StartMachine (StateMachine ):
77+ class StartMachine (StateChart ):
7878 created = State (initial = True )
7979 started = State (final = True )
8080
@@ -90,7 +90,7 @@ class StartMachine(StateMachine):
9090 def test_raise_invalid_definition_if_event_name_cannot_be_derived (self ):
9191 with pytest .raises (InvalidDefinition , match = "has no id" ):
9292
93- class StartMachine (StateMachine ):
93+ class StartMachine (StateChart ):
9494 created = State (initial = True )
9595 started = State ()
9696
@@ -99,7 +99,7 @@ class StartMachine(StateMachine):
9999 started .to .itself (event = Event ()) # event id not defined
100100
101101 def test_derive_from_id (self ):
102- class StartMachine (StateMachine ):
102+ class StartMachine (StateChart ):
103103 created = State (initial = True )
104104 started = State ()
105105
@@ -108,7 +108,7 @@ class StartMachine(StateMachine):
108108 assert StartMachine .launch_rocket .name == "Launch rocket"
109109
110110 def test_of_passing_event_as_parameters (self ):
111- class TrafficLightMachine (StateMachine ):
111+ class TrafficLightMachine (StateChart ):
112112 "A traffic light machine"
113113
114114 green = State (initial = True )
@@ -142,7 +142,7 @@ def on_cycle(self, event_data, event: str):
142142 assert sm .go .name == "Go! Go! Go!"
143143
144144 def test_mixing_event_and_parameters (self ):
145- class TrafficLightMachine (StateMachine ):
145+ class TrafficLightMachine (StateChart ):
146146 "A traffic light machine"
147147
148148 green = State (initial = True )
@@ -174,7 +174,7 @@ def on_cycle(self, event_data, event: str):
174174 assert sm .go .name == "Go! Go! Go!"
175175
176176 def test_name_derived_from_identifier (self ):
177- class TrafficLightMachine (StateMachine ):
177+ class TrafficLightMachine (StateChart ):
178178 "A traffic light machine"
179179
180180 green = State (initial = True )
@@ -205,7 +205,7 @@ def on_cycle(self, event_data, event: str):
205205 assert sm .go .name == "go"
206206
207207 def test_multiple_ids_from_the_same_event_will_be_converted_to_multiple_events (self ):
208- class TrafficLightMachine (StateMachine ):
208+ class TrafficLightMachine (StateChart ):
209209 "A traffic light machine"
210210
211211 green = State (initial = True )
@@ -234,7 +234,7 @@ def on_cycle(self, event_data, event: str):
234234 assert sm .send ("cycle" ) == "Running cycle from red to green"
235235
236236 def test_allow_registering_callbacks_using_decorator (self ):
237- class TrafficLightMachine (StateMachine ):
237+ class TrafficLightMachine (StateChart ):
238238 "A traffic light machine"
239239
240240 green = State (initial = True )
@@ -263,7 +263,7 @@ def do_cycle(self, event_data, event: str):
263263 def test_raise_registering_callbacks_using_decorator_if_no_transitions (self ):
264264 with pytest .raises (InvalidDefinition , match = "event with no transitions" ):
265265
266- class TrafficLightMachine (StateMachine ):
266+ class TrafficLightMachine (StateChart ):
267267 "A traffic light machine"
268268
269269 green = State (initial = True )
@@ -285,7 +285,7 @@ def do_cycle(self, event_data, event: str):
285285 )
286286
287287 def test_allow_using_events_as_commands (self ):
288- class StartMachine (StateMachine ):
288+ class StartMachine (StateChart ):
289289 created = State (initial = True )
290290 started = State ()
291291
@@ -299,7 +299,7 @@ class StartMachine(StateMachine):
299299 assert sm .started .is_active
300300
301301 def test_event_commands_fail_when_unbound_to_instance (self ):
302- class StartMachine (StateMachine ):
302+ class StartMachine (StateChart ):
303303 created = State (initial = True )
304304 started = State ()
305305
0 commit comments