def test_stateMachine_transitions_byGoto(self): """Test State Transations from State 1 to State2.""" machine = StateMachine(State1) self.assertRaises(StateError, machine.goto, State1) self.assertTrue(machine.inState(State1)) machine.goto(State2) self.assertEqual(machine.message, 'Entered State 2') self.assertTrue(machine.inState(State2))
def test_stateMachine_finalState(self): """Test Final State.""" machine = StateMachine(State1) self.assertTrue(machine.inState(State1)) machine.goto(State2) self.assertTrue(machine.inState(State2)) self.assertFalse(State1 in machine.state.movesTo) self.assertFalse(State2 in machine.state.movesTo) self.assertRaises(StateError, machine.goto, State1) self.assertRaises(StateError, machine.goto, State2) self.assertTrue(machine.inState(State2))