Exemplo n.º 1
0
 def test_fsm_idle(self):
     expected = ['StateA1:i']
     sm = test_simplefsm.SimpleFSM()
     sm.do_terminate()
     sm.wait()
     retval = sm.out_seq
     self.assertEqual(
         retval,
         expected,
         '{} is not as expected {}'.format(retval, expected))
Exemplo n.º 2
0
 def test_fsm_state_count(self):
     expected = 7
     sm = test_simplefsm.SimpleFSM()
     sm.do_terminate()
     sm.wait()
     retval = len(sm.states)
     self.assertEqual(
         retval,
         expected,
         '{} is not as expected {}'.format(retval, expected))
Exemplo n.º 3
0
 def test_fsm_state_depth(self):
     expected = 1
     sm = test_simplefsm.SimpleFSM()
     sm.do_terminate()
     sm.wait()
     retval = sm.depth
     self.assertEqual(
         retval,
         expected,
         '{} is not as expected {}'.format(retval, expected))
Exemplo n.º 4
0
 def test_fsm_state_adding(self):
     expected = [
         'StateA1',
         'StateA2',
         'StateA3',
         'StateA4',
         'StateA5',
         'StateA6',
         'StateA7'
         ]
     sm = test_simplefsm.SimpleFSM()
     sm.do_terminate()
     sm.wait()
     retval = sm.added_states
     self.assertEqual(
         set(retval),
         set(expected),
         '{} is not as expected {}'.format(retval, expected))
Exemplo n.º 5
0
 def test_hsm_transitions(self):
     event_ids = (
         'a',
         'a',
         'a',
         'a',
         'a',
         'a',
         'a')
     expected = (
         'StateA1:i',
         'StateA1:x',
         'StateA2:e',
         'StateA2:i',
         'StateA2:x',
         'StateA3:e',
         'StateA3:i',
         'StateA3:x',
         'StateA4:e',
         'StateA4:i',
         'StateA4:x',
         'StateA5:e',
         'StateA5:i',
         'StateA5:x',
         'StateA6:e',
         'StateA6:i',
         'StateA6:x',
         'StateA7:e',
         'StateA7:i',
         'StateA7:x',
         'StateA1:e',
         'StateA1:i'
         )
     sm = test_simplefsm.SimpleFSM()
     for event_id in event_ids:
         sm.send(fsm.Event(event_id))
     sm.do_terminate()
     sm.wait()
     retval = sm.out_seq
     self.assertEqual(
         tuple(retval),
         expected,
         '{} is not as expected {}'.format(retval, expected))
Exemplo n.º 6
0
 def test_fsm_missing_transitions(self):
     expected = [
         'StateA1:i',
         'StateA1:x',
         'StateA2:e',
         'StateA2:i'
         ]
     sm = test_simplefsm.SimpleFSM()
     event = fsm.Event('a')
     sm.send(event)
     event = fsm.Event('b')
     sm.send(event)
     sm.do_terminate()
     sm.wait()
     retval = sm.out_seq
     self.assertEqual(
         retval,
         expected,
         '{} is not as expected {}'.format(retval, expected))
Exemplo n.º 7
0
 def test_fsm_simple_transitions(self):
     expected = [
         'StateA1:i',
         'StateA1:x',
         'StateA2:e',
         'StateA2:i',
         'StateA2:x',
         'StateA3:e',
         'StateA3:i',
         'StateA3:x',
         'StateA4:e',
         'StateA4:i',
         'StateA4:x',
         'StateA5:e',
         'StateA5:i',
         'StateA5:x',
         'StateA6:e',
         'StateA6:i',
         'StateA6:x',
         'StateA7:e',
         'StateA7:i',
         'StateA7:x',
         'StateA1:e',
         'StateA1:i'
         ]
     sm = test_simplefsm.SimpleFSM()
     event = fsm.Event('a')
     for _ in range(7):
         sm.send(event)
     sm.do_terminate()
     sm.wait()
     retval = sm.out_seq
     self.assertEqual(
         retval,
         expected,
         '{} is not as expected {}'.format(retval, expected))