예제 #1
0
    def test_destination_reached(self):
        with open(
                'docs/examples/tester_elevator_destination_reached.yaml') as f:
            tester_statechart = io.import_from_yaml(f)

        # Create the interpreter and the watcher
        watcher = ExecutionWatcher(self.tested)

        # Add the tester and start watching
        tester = watcher.watch_with(tester_statechart)
        watcher.start()

        # Send the elevator to 4th
        self.tested.queue(Event('floorSelected', floor=4)).execute(max_steps=2)
        self.assertEqual(tester.context['destinations'], [4])

        self.tested.execute()
        self.assertEqual(tester.context['destinations'], [])

        # Stop watching. The tester must be in a final state
        watcher.stop()

        self.assertFalse(tester.final)
예제 #2
0
 def setUp(self):
     with open('docs/examples/elevator.yaml') as f:
         sc = io.import_from_yaml(f)
     self.tested = Interpreter(sc)
     self.watcher = ExecutionWatcher(self.tested)