Esempio n. 1
0
 def test_parseSyntaxMethod_02(self):
     parseSyntax(self.example_string)
     pcb_x = ProcessManager().getProcessByName('X')
     workplan = pcb_x.process.workplan
     plan_soll = Workplan().work(90)
     self.assertListEqual(plan_soll.plan,
                          workplan.plan)
Esempio n. 2
0
    def post(self, strategy, quantum=4, ts=10):
        #import pdb; pdb.set_trace()

        # parse process syntax
        args = self.parser.parse_args()
        processDescription = args.get("syntax")
        init_p = args.get("initial_process")
        # trying to parse the syntax
        parseSyntax(processDescription)

        # here comes the critical section: creating the Scheduler environmet including Singletons.
        try:
            # generate scheduler
            scheduler = SchedulerFactory.getScheduler(str(strategy),
                                                      quantum=quantum,
                                                      timeslice=ts)
            # run scheduler
            scheduler.initialize(init_p)
            scheduler.run()
            # generate JSON
            json_result = JsonSerializer().generateData()
        except Exception as e:
            # pass the exceptions to the api - it will translate it to json-requests
            raise e
        finally:
            # we make sure that even after an exception, all Singletons get destroyed.
            ProcessManager._drop()
            SystemTimer._drop()

        return json_result, 200
Esempio n. 3
0
 def test_parseOneliner(self):
     parseSyntax(self.oneliner_string)
     pcb_x = ProcessManager().getProcessByName("X")
     plan_soll = Workplan().work(90)
     plan_ist = pcb_x.process.workplan
     self.assertListEqual(plan_soll.plan, plan_ist.plan)
Esempio n. 4
0
 def test_parseSyntaxMethod(self):
     # execute syntaxparser
     parseSyntax(self.example_string)
     jobs = ProcessManager().jobs
     print 'JOOOBS', jobs
     self.assertTrue(len(jobs) == 3)