def __call__(self): if not (self.__di_params): raise ScenarioFileInvalid( "Dependeny Injection parameters are essential after %s" % self.__di_key) if not (self.__di_params.get("class")): raise ScenarioFileInvalid("class: is not specified after %s" % self.__di_key)
def __call__(self): """ Validate parsed scenario.yml instance type """ yaml_dict = self._val if not isinstance(yaml_dict, dict): raise ScenarioFileInvalid( "scenario.yml is invalid. Check scenario.yml format.")
def __call__(self): """ Validate scenario key in scenario.yml """ yaml_dict = self._val scenario = yaml_dict.get("scenario") if not scenario: raise ScenarioFileInvalid( "scenario.yml is invalid. 'scenario:' key does not exist, or 'scenario:' key exists but content under 'scenario:' key does not exist." )
def create_scenario_queue(self): self._logger.info("Start to create scenario queue") # validation self.__valid_essential_dir() self.__valid_essential_files() # parse scenario.yml parser = YamlScenarioParser(self._pj_scenario_file, self._cmn_scenario_file) yaml_scenario_list = parser.parse() if yaml_scenario_list and isinstance(yaml_scenario_list, list): self.__invoke_steps(yaml_scenario_list) else: raise ScenarioFileInvalid("scenario.yml is invalid.") self._logger.info("Finish to create scenario queue")
def __replace_vars(self, yaml_v, var_name): """ Replace {{ var }} in string Args: yaml_v: replace target value var_name: means {{ var }} itself """ cmd = self._dynamic_key_and_val[var_name] if not cmd: raise ScenarioFileInvalid( "scenario.yml is invalid. 'with_vars' definition against %s does not exist." # noqa % var_name) shell_output = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True).communicate()[0] shell_output = shell_output.strip() # remove head byte string shell_output = re.sub("^b", "", str(shell_output)) # remove ' shell_output = re.sub("'", "", str(shell_output)) return re.sub(r"{{(.*?)%s(.*?)}}" % var_name, shell_output, yaml_v)
def __exists_class(self, dict): if not dict.get("class"): raise ScenarioFileInvalid( "scenario.yml is invalid. 'class:' key does not exist, or 'class:' value does not exist." )
def __exists_step(self, dict): if "step" not in dict.keys(): raise ScenarioFileInvalid( "scenario.yml is invalid. 'step:' does not exist.")
def __call__(self): if self.__io != "output": raise ScenarioFileInvalid("io: output is not specified.")