def __invoke_steps(self, yaml_scenario_list): """ Create executable instance and push them to queue Args: yaml_scenario_list: parsed yaml list """ self._logger.info("Start to invoke scenario") # Create queue to save step instances q = StepQueue() for s_dict in yaml_scenario_list: if "multi_process_count" in s_dict.keys(): q.multi_proc_cnt = s_dict.get("multi_process_count") continue if "force_continue" in s_dict.keys(): q.force_continue = s_dict.get("force_continue") continue instances = [] if "parallel" in s_dict.keys(): for row in s_dict.get("parallel"): instance = self.__create_instance(row, yaml_scenario_list) Helper.set_property( instance, "logger", LisboaLog.get_logger(instance.__class__.__name__), ) instances.append(instance) StepArgument._put(row["step"], instance) else: instance = self.__create_instance(s_dict, yaml_scenario_list) Helper.set_property( instance, "logger", LisboaLog.get_logger(instance.__class__.__name__), ) instances.append(instance) StepArgument._put(s_dict["step"], instance) # Put instance to queue q.push(instances) # save queue to static area setattr(ScenarioQueue, "step_queue", q) self._logger.info("Finish to invoke scenario")
class TestScenairoQueue(object): def setup_method(self): self._scenario_queue = StepQueue() def test_push_and_pop(self): instance = "spam" self._scenario_queue.push(instance) ret = self._scenario_queue.pop() ret == "spam" def test_size(self): instance = "spam" self._scenario_queue.push(instance) size = self._scenario_queue.size() # remove test data in queue self._scenario_queue.pop() assert size == 1 def test_is_empty(self): is_empty = self._scenario_queue.is_empty() assert is_empty is True
class TestStepQueue(object): _DUMMY_PARALLEL_CNT = 9 def setup_method(self): self._scenario_queue = StepQueue() def test_multi_proc_cnt(self): self._scenario_queue.multi_proc_cnt = self._DUMMY_PARALLEL_CNT assert self._scenario_queue.multi_proc_cnt == self._DUMMY_PARALLEL_CNT def test_push_and_pop(self): instance = "spam" self._scenario_queue.push(instance) ret = self._scenario_queue.pop() ret == "spam" def test_peek(self): instance = "spam" self._scenario_queue.push(instance) assert self._scenario_queue.peek() == "spam" def test_size(self): instance = "spam" self._scenario_queue.push(instance) size = self._scenario_queue.size() # remove test data in queue self._scenario_queue.pop() assert size == 1 def test_is_empty(self): is_empty = self._scenario_queue.is_empty() assert is_empty is True