本文整理匯總了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)
)