def test_never_finished_if_final_is_unspecified(self):
     fsm = Fysom({
         'initial':
         'green',
         'events': [{
             'name': 'warn',
             'src': 'green',
             'dst': 'yellow'
         }, {
             'name': 'panic',
             'src': 'yellow',
             'dst': 'red'
         }, {
             'name': 'calm',
             'src': 'red',
             'dst': 'yellow'
         }, {
             'name': 'clear',
             'src': 'yellow',
             'dst': 'green'
         }]
     })
     self.assertFalse(fsm.is_finished())
     fsm.warn()
     self.assertFalse(fsm.is_finished())
     fsm.panic()
     self.assertFalse(fsm.is_finished())
 def test_it_should_indicate_whether_fsm_in_finished_state(self):
     fsm = Fysom({
         'initial':
         'green',
         'final':
         'red',
         'events': [{
             'name': 'warn',
             'src': 'green',
             'dst': 'yellow'
         }, {
             'name': 'panic',
             'src': 'yellow',
             'dst': 'red'
         }, {
             'name': 'calm',
             'src': 'red',
             'dst': 'yellow'
         }, {
             'name': 'clear',
             'src': 'yellow',
             'dst': 'green'
         }]
     })
     self.assertFalse(fsm.is_finished())
     fsm.warn()
     self.assertFalse(fsm.is_finished())
     fsm.panic()
     self.assertTrue(fsm.is_finished())
 def test_never_finished_if_final_is_unspecified(self):
     fsm = Fysom({
         'initial': 'green',
         'events': [
             {'name': 'warn', 'src': 'green', 'dst': 'yellow'},
             {'name': 'panic', 'src': 'yellow', 'dst': 'red'},
             {'name': 'calm', 'src': 'red', 'dst': 'yellow'},
             {'name': 'clear', 'src': 'yellow', 'dst': 'green'}
         ]
     })
     self.assertFalse(fsm.is_finished())
     fsm.warn()
     self.assertFalse(fsm.is_finished())
     fsm.panic()
     self.assertFalse(fsm.is_finished())
 def test_it_should_indicate_whether_fsm_in_finished_state(self):
     fsm = Fysom({
         'initial': 'green',
         'final': 'red',
         'events': [
             {'name': 'warn', 'src': 'green', 'dst': 'yellow'},
             {'name': 'panic', 'src': 'yellow', 'dst': 'red'},
             {'name': 'calm', 'src': 'red', 'dst': 'yellow'},
             {'name': 'clear', 'src': 'yellow', 'dst': 'green'}
         ]
     })
     self.assertFalse(fsm.is_finished())
     fsm.warn()
     self.assertFalse(fsm.is_finished())
     fsm.panic()
     self.assertTrue(fsm.is_finished())
 def test_final_kwarg(self):
     fsm = Fysom(initial='eternity', final='eternity')
     self.assertEqual(fsm.current, 'eternity')
     self.assertEqual(fsm.is_finished(), True)
Example #6
0
 def test_final_kwarg(self):
     fsm = Fysom(initial='eternity', final='eternity')
     self.assertEqual(fsm.current, 'eternity')
     self.assertEqual(fsm.is_finished(), True)