tests: Allow to test project parameters

So far it wasn't possible to test the prameters of the
project itself. While If7b749dae7631e8714a9416dfbd82d2443c0302c
already made the job creation consistent this goes one step further
and creates the root_xml using the project's root_xml method.

Change-Id: Ieba4203d3d23ad68df5a1246e90ea8c03ddd54d4
This commit is contained in:
Guido Günther 2014-01-16 12:14:15 +01:00
parent b47fe61905
commit d1846e7dfc
5 changed files with 60 additions and 12 deletions

View File

@ -25,6 +25,10 @@ import testtools
import xml.etree.ElementTree as XML import xml.etree.ElementTree as XML
import yaml import yaml
from jenkins_jobs.builder import XmlJob, YamlParser, ModuleRegistry from jenkins_jobs.builder import XmlJob, YamlParser, ModuleRegistry
from jenkins_jobs.modules import (project_flow,
project_matrix,
project_maven,
project_multijob)
def get_scenarios(fixtures_path): def get_scenarios(fixtures_path):
@ -75,21 +79,21 @@ class BaseTestCase(object):
return return
yaml_content, expected_xml = self.__read_content() yaml_content, expected_xml = self.__read_content()
project = None
root_element = XML.Element('project')
if ('project-type' in yaml_content): if ('project-type' in yaml_content):
if (yaml_content['project-type'] == "maven"): if (yaml_content['project-type'] == "maven"):
root_element = XML.Element('maven2-moduleset') project = project_maven.Maven(None)
if (yaml_content['project-type'] == "matrix"): elif (yaml_content['project-type'] == "matrix"):
root_element = XML.Element('matrix-project') project = project_matrix.Matrix(None)
if (yaml_content['project-type'] == "flow"): elif (yaml_content['project-type'] == "flow"):
root_element = XML.Element('com.cloudbees.plugins.flow.' project = project_flow.Flow(None)
'BuildFlow') elif (yaml_content['project-type'] == "multijob"):
if (yaml_content['project-type'] == "multijob"): project = project_multijob.MultiJob(None)
root_element = XML.Element('com.tikal.jenkins.plugins.'
'multijob.MultiJobProject')
xml_project = root_element if project:
xml_project = project.root_xml(yaml_content)
else:
xml_project = XML.Element('project')
parser = YamlParser() parser = YamlParser()
pub = self.klass(ModuleRegistry({})) pub = self.klass(ModuleRegistry({}))

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<maven2-moduleset>
<rootModule>
<groupId>gabba.gabba</groupId>
<artifactId>hey</artifactId>
</rootModule>
<goals>deploy</goals>
<ignoreUpstremChanges>true</ignoreUpstremChanges>
<rootPOM>pom.xml</rootPOM>
<aggregatorStyleBuild>true</aggregatorStyleBuild>
<incrementalBuild>false</incrementalBuild>
<perModuleEmail>true</perModuleEmail>
<archivingDisabled>false</archivingDisabled>
<resolveDependencies>false</resolveDependencies>
<processPlugins>false</processPlugins>
<mavenValidationLevel>-1</mavenValidationLevel>
<runHeadless>false</runHeadless>
<settingConfigId/>
<globalSettingConfigId/>
<runPostStepsIfResult>
<name>FAILURE</name>
<ordinal>2</ordinal>
<color>red</color>
</runPostStepsIfResult>
<actions/>
<keepDependencies>false</keepDependencies>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<concurrentBuild>false</concurrentBuild>
<canRoam>true</canRoam>
</maven2-moduleset>

View File

@ -0,0 +1,7 @@
project-type: maven
maven:
root-pom: pom.xml
goals: deploy
root-module:
group-id: gabba.gabba
artifact-id: hey

View File

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<matrix-project> <matrix-project>
<executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
<runSequentially>false</runSequentially>
</executionStrategy>
<combinationFilter/>
<axes/>
<actions/> <actions/>
<keepDependencies>false</keepDependencies> <keepDependencies>false</keepDependencies>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.cloudbees.plugins.flow.BuildFlow> <com.cloudbees.plugins.flow.BuildFlow>
<dsl/>
<actions/> <actions/>
<keepDependencies>false</keepDependencies> <keepDependencies>false</keepDependencies>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>