def test_retain_anchors_enabled(self): """ Verify that anchors are retained across files if retain_anchors is enabled in the config. """ files = ["custom_retain_anchors_include001.yaml", "custom_retain_anchors.yaml"] jjb_config = JJBConfig() jjb_config.yamlparser['retain_anchors'] = True jjb_config.validate() j = YamlParser(jjb_config) j.load_files([os.path.join(self.fixtures_path, f) for f in files])
def test_retain_anchors_default(self): """ Verify that anchors are NOT retained across files by default. """ files = ["custom_retain_anchors_include001.yaml", "custom_retain_anchors.yaml"] jjb_config = JJBConfig() # use the default value for retain_anchors jjb_config.validate() j = YamlParser(jjb_config) with ExpectedException(yaml.composer.ComposerError, "found undefined alias.*"): j.load_files([os.path.join(self.fixtures_path, f) for f in files])
def setUp(self): super(ModuleRegistryPluginInfoTestsWithScenarios, self).setUp() jjb_config = JJBConfig() jjb_config.validate() plugin_info = [{ "shortName": "HerpDerpPlugin", "longName": "Blah Blah Blah Plugin" }] plugin_info.append({ "shortName": "JankyPlugin1", "longName": "Not A Real Plugin", "version": self.v1, }) self.addDetail("plugin_info", text_content(str(plugin_info))) self.registry = ModuleRegistry(jjb_config, plugin_info)
def __init__(self, args=None, **kwargs): if args is None: args = [] self.parser = create_parser() self.options = self.parser.parse_args(args) self.jjb_config = JJBConfig(self.options.conf, **kwargs) if not self.options.command: self.parser.error("Must specify a 'command' to be performed") if (self.options.log_level is not None): self.options.log_level = getattr(logging, self.options.log_level.upper(), logger.getEffectiveLevel()) logger.setLevel(self.options.log_level) self._parse_additional() self.jjb_config.validate()
def test_multiple_same_anchor_in_multiple_toplevel_yaml(self): """ Verify that anchors/aliases only span use of '!include' tag To ensure that any yaml loaded by the include tag is in the same space as the top level file, but individual top level yaml definitions are treated by the yaml loader as independent. """ files = ["custom_same_anchor-001-part1.yaml", "custom_same_anchor-001-part2.yaml"] jjb_config = JJBConfig() jjb_config.jenkins['url'] = 'http://example.com' jjb_config.jenkins['user'] = '******' jjb_config.jenkins['password'] = '******' jjb_config.builder['plugins_info'] = [] jjb_config.validate() j = YamlParser(jjb_config) j.load_files([os.path.join(self.fixtures_path, f) for f in files])
def test_retain_anchors_enabled_j2_yaml(self): """ Verify that anchors are retained across files and are properly retained when using !j2-yaml. """ files = [ "custom_retain_anchors_j2_yaml_include001.yaml", "custom_retain_anchors_j2_yaml.yaml", ] jjb_config = JJBConfig() jjb_config.yamlparser["retain_anchors"] = True jjb_config.validate() j = YamlParser(jjb_config) j.load_files([os.path.join(self.fixtures_path, f) for f in files]) registry = ModuleRegistry(jjb_config, None) jobs, _ = j.expandYaml(registry) self.assertEqual(jobs[0]["builders"][0]["shell"], "docker run ubuntu:latest")
def assert_case(case_name): case_source, case_result = (os.path.join(BASE_PATH, case_name + ext) for ext in ['.yml', '.xml']) jjb_config = JJBConfig() builder = Builder(jjb_config) # Generate XML parser = YamlParser(jjb_config) registry = ModuleRegistry(jjb_config, builder.plugins_list) xml_generator = XmlJobGenerator(registry) parser.load_files(case_source) registry.set_parser_data(parser.data) job_data_list = parser.expandYaml(registry, []) xml_jobs = xml_generator.generateXML(job_data_list) result_xml = ET.XML(xml_jobs[0].output()) expected_xml = ET.XML(open(case_result).read()) assert ET.tostring(result_xml) == ET.tostring(expected_xml)
def _get_config(self): jjb_config = JJBConfig(self.conf_filename) jjb_config.validate() return jjb_config
def setUp(self): super(TestCaseTestJenkinsManager, self).setUp() self.jjb_config = JJBConfig() self.jjb_config.validate()
def setUp(self): super(TestCaseTestBuilder, self).setUp() jjb_config = JJBConfig() jjb_config.builder['plugins_info'] = ['plugin1', 'plugin2'] jjb_config.validate() self.builder = jenkins_jobs.builder.Builder(jjb_config)
def setUp(self): super(TestCaseTestBuilder, self).setUp() self.jjb_config = JJBConfig() self.jjb_config.validate()