def test_generate_01(self): serializer = JsonSerializer() data = serializer.generateJson() print data try: json.loads(data) except ValueError: self.fail("json not valid")
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
def test_generate_data(self): serializer = JsonSerializer() data = serializer.generateData() print data self.assertIsInstance(data, dict)