Esempio n. 1
0
    def generic_test(self,
                     tested_statechart: Statechart,
                     events: list,
                     property: Condition,
                     expected_success: bool,
                     expected_failure: bool):
        from sismic.interpreter import log_trace
        tester_statechart = Statechart('tester_statechart')

        tester_statechart.add_state(OrthogonalState('parallel_state'), None)
        tester_statechart.add_state(CompoundState('testing_area', initial='property'), parent='parallel_state')
        tester_statechart.add_state(BasicState('success_state'), parent='testing_area')
        tester_statechart.add_state(BasicState('failure_state'), parent='testing_area')

        property.add_to(tester_statechart,
                        id='property',
                        parent_id='testing_area',
                        status_id='parallel_state',
                        success_id='success_state',
                        failure_id='failure_state')

        tester_interpreter = Interpreter(tester_statechart)

        self.assertFalse('success_state' in tester_interpreter.configuration)
        self.assertFalse('failure_state' in tester_interpreter.configuration)

        tested_interpreter = Interpreter(tested_statechart)
        trace = log_trace(tested_interpreter)

        for event in events:
            tested_interpreter.queue(event)

        tested_interpreter.execute()

        story = teststory_from_trace(trace)
        story.tell(tester_interpreter)

        self.assertEqual(expected_success, 'success_state' in tester_interpreter.configuration)
        self.assertEqual(expected_failure, 'failure_state' in tester_interpreter.configuration)
Esempio n. 2
0
 def setUp(self):
     with open('docs/examples/elevator.yaml') as f:
         sc = io.import_from_yaml(f)
     self.tested = Interpreter(sc)
     self.steps = log_trace(self.tested)
Esempio n. 3
0
 def setUp(self):
     with open('docs/examples/elevator.yaml') as f:
         sc = io.import_from_yaml(f)
     self.tested = Interpreter(sc)
     self.steps = log_trace(self.tested)