def validate_template(self, ctx, templates): LOG.debug("TemplateApis validate_template templates:" "%s", str(templates)) results = [] for template in templates: template_definition = template[1] path = template[0] syntax_result = syntax_validation(template_definition) if not syntax_result.is_valid_config: self._add_result(path, self.FAILED_MSG, syntax_result.description, syntax_result.comment, syntax_result.status_code, results) continue content_result = content_validation(template_definition, self.def_templates) if not content_result.is_valid_config: self._add_result(path, self.FAILED_MSG, content_result.description, content_result.comment, content_result.status_code, results) continue self._add_result(path, self.OK_MSG, 'Template validation', status_msgs[0], 0, results) return json.dumps({'results': results})
def add_template(self, template_def): result = syntax_validation(template_def) if not result.is_valid_config: LOG.info('Unable to load template, syntax err: %s' % result.comment) else: result = content_validation(template_def, self._def_templates) if not result.is_valid_config: LOG.info('Unable to load template, content err: %s' % result.comment) template_uuid = uuidutils.generate_uuid() current_time = datetime_utils.utcnow() self.templates[str(template_uuid)] = Template(template_uuid, template_def, current_time, result) if result.is_valid_config: template_data = \ TemplateLoader().load(template_def, self._def_templates) for scenario in template_data.scenarios: for equivalent_scenario in self._expand_equivalence(scenario): self._add_scenario(equivalent_scenario)
def _execute_and_assert_with_fault_result(self, template, status_code, def_temps={}): result = validator.content_validation(template, def_temps) self._assert_fault_result(result, status_code)
def _execute_and_assert_with_correct_result(self, template, def_temps=None): if def_temps is None: def_temps = {} result = validator.content_validation(template, def_temps) self._assert_correct_result(result)
def validate_template(template, def_templates): result = syntax_validation(template) if not result.is_valid_config: LOG.error('Unable to load template, syntax error: %s' % result.comment) return result result = content_validation(template, def_templates) if not result.is_valid_config: LOG.error('Unable to load template, content error:%s' % result.comment) return result return result