def _test_instance_inited(): Global.set_time_manager(Mock()) test = Test() status_manager = StatusManager(port=None) script_reader = JSONScriptReader( 'functional_tests/cfe_6_7_tests/cfe_tests/CfeEsTest.json') script_reader.process_tests() script_list = [script_reader.script] status_manager.set_scripts(script_list) instructions = script_reader.script.tests[0].instructions test.instructions = instructions status_manager.start() test.status_manager = status_manager return test
def process_tests(self): """ Iterates over test cases within the test script and parses each test case. """ tests = self.raw_data.get("tests") test_list = [] if tests is None: self.script.set_tests(test_list) self.valid_script = False return # Build event list for curr_test in tests: instruction_list = [] test = Test() commands = curr_test["instructions"] default_index = -1 for _, command in enumerate(commands): data = command.get("data") args = None if data is None else data.get("args") args = self.sanitize_args(args) if args is not None: command["args"] = args if "function" in command: params = None if command is None else command.get("params") params = self.sanitize_args(params) if params is not None: command["params"] = params inline_commands = self.resolve_function(command["function"], command["params"], self.functions) if inline_commands is None: log.error("Failed to process test case due to the error(s) above. Skipping {}".format( curr_test["case_number"] )) instruction_list = [] break if not inline_commands: log.error("No commands in function {}".format(command["function"])) continue if "wait" in command: function_call_delay = command["wait"] else: function_call_delay = 1.0 function_disabled = bool(command.get('disabled', False)) for c_index, c_inline in enumerate(inline_commands): delay = 0 if "wait" in c_inline.keys(): delay = c_inline["wait"] if c_index == 0: delay += function_call_delay disabled = function_disabled or bool(c_inline.get('disabled', False)) instruction_list.append(Instruction(delay, c_inline, len(test_list), default_index, disabled)) else: delay = 0 if "wait" in command.keys(): delay = command["wait"] disabled = bool(command.get('disabled', False)) instruction_list.append(Instruction(delay, command, len(test_list), default_index, disabled)) for i, _ in enumerate(instruction_list): instruction_list[i].command_index = i test.test_info = {"test_case": curr_test["case_number"], "description": curr_test["description"]} test.instructions = instruction_list test_list.append(test) self.script.set_tests(test_list)