本文整理汇总了Python中jenkins_jobs.parser.YamlParser._getfullname方法的典型用法代码示例。如果您正苦于以下问题:Python YamlParser._getfullname方法的具体用法?Python YamlParser._getfullname怎么用?Python YamlParser._getfullname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jenkins_jobs.parser.YamlParser
的用法示例。
在下文中一共展示了YamlParser._getfullname方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_yaml_snippet
# 需要导入模块: from jenkins_jobs.parser import YamlParser [as 别名]
# 或者: from jenkins_jobs.parser.YamlParser import _getfullname [as 别名]
def test_yaml_snippet(self):
if not self.in_filename:
return
jjb_config = self._get_config()
expected_xml = self._read_utf8_content()
yaml_content = self._read_yaml_content(self.in_filename)
plugins_info = None
if self.plugins_info_filename:
plugins_info = self._read_yaml_content(self.plugins_info_filename)
self.addDetail("plugins-info-filename",
text_content(self.plugins_info_filename))
self.addDetail("plugins-info",
text_content(str(plugins_info)))
parser = YamlParser(jjb_config)
registry = ModuleRegistry(jjb_config, plugins_info)
registry.set_parser_data(parser.data)
pub = self.klass(registry)
project = None
if ('project-type' in yaml_content):
if (yaml_content['project-type'] == "maven"):
project = project_maven.Maven(registry)
elif (yaml_content['project-type'] == "matrix"):
project = project_matrix.Matrix(registry)
elif (yaml_content['project-type'] == "flow"):
project = project_flow.Flow(registry)
elif (yaml_content['project-type'] == "multijob"):
project = project_multijob.MultiJob(registry)
elif (yaml_content['project-type'] == "multibranch"):
project = project_multibranch.WorkflowMultiBranch(registry)
elif (yaml_content['project-type'] == "multibranch-defaults"):
project = project_multibranch.WorkflowMultiBranchDefaults(registry) # noqa
elif (yaml_content['project-type'] == "externaljob"):
project = project_externaljob.ExternalJob(registry)
if 'view-type' in yaml_content:
if yaml_content['view-type'] == "all":
project = view_all.All(None)
elif yaml_content['view-type'] == "list":
project = view_list.List(None)
elif yaml_content['view-type'] == "pipeline":
project = view_pipeline.Pipeline(None)
else:
raise InvalidAttributeError(
'view-type', yaml_content['view-type'])
if project:
xml_project = project.root_xml(yaml_content)
else:
xml_project = XML.Element('project')
# Generate the XML tree directly with modules/general
pub.gen_xml(xml_project, yaml_content)
# check output file is under correct path
if 'name' in yaml_content:
prefix = os.path.dirname(self.in_filename)
# split using '/' since fullname uses URL path separator
expected_folders = [os.path.normpath(
os.path.join(prefix,
'/'.join(parser._getfullname(yaml_content).
split('/')[:-1])))]
actual_folders = [os.path.dirname(f) for f in self.out_filenames]
self.assertEquals(
expected_folders, actual_folders,
"Output file under wrong path, was '%s', should be '%s'" %
(self.out_filenames[0],
os.path.join(expected_folders[0],
os.path.basename(self.out_filenames[0]))))
# Prettify generated XML
pretty_xml = XmlJob(xml_project, 'fixturejob').output().decode('utf-8')
self.assertThat(
pretty_xml,
testtools.matchers.DocTestMatches(expected_xml,
doctest.ELLIPSIS |
doctest.REPORT_NDIFF)
)