def get_context_data(self, **kwargs): """ Supplement the dependency. """ context = super( DependencyUpdateView, self).get_context_data(**kwargs) params = [x for x in parse_parameters_from_job(self.object.job.jobtype.config_xml) if x["name"] != "BUILD_ID"] context["parameters"] = params return context
def test_parse_parameters_from_job(self): """ """ self.assertEqual([ {"name": "BUILD_ID", "description": "The projectbuild id to associate with.", "defaultValue": None}, {"name": "BRANCH_TO_CHECKOUT", "description": "Branch to checkout and build.", "defaultValue": "http:///launchpad.net/mybranch"}], parse_parameters_from_job(job_with_parameters))
def test_parse_parameters_from_job(self): """ parse_parameters_from_job should extract the parameters from the job XML document and return the details. """ jobtype = JobTypeWithParamsFactory.build() self.assertEqual([ {"name": "BUILD_ID", "description": "The projectbuild id to associate with.", "defaultValue": None}, {"name": "BRANCH_TO_CHECKOUT", "description": "Branch to checkout and build.", "defaultValue": "http:///launchpad.net/mybranch"}], parse_parameters_from_job(jobtype.config_xml))
def test_parse_parameters_from_job(self): """ parse_parameters_from_job should extract the parameters from the job XML document and return the details. """ jobtype = JobTypeWithParamsFactory.build() self.assertEqual([{ "name": "BUILD_ID", "description": "The projectbuild id to associate with.", "defaultValue": None }, { "name": "BRANCH_TO_CHECKOUT", "description": "Branch to checkout and build.", "defaultValue": "http:///launchpad.net/mybranch" }], parse_parameters_from_job(jobtype.config_xml))
def test_add_parameter_to_job(self): """ add_parameter_to_job adds the XML for a JenkinsParameter to a Jenkins job document. """ parameter = JenkinsParameter("TEST_ID", "Testing Element", "DEFAULT") jobtype = JobTypeWithParamsFactory.build() new_xml = add_parameter_to_job(parameter, jobtype.config_xml) self.assertEqual([ {"name": "BUILD_ID", "description": "The projectbuild id to associate with.", "defaultValue": None}, {"name": "BRANCH_TO_CHECKOUT", "description": "Branch to checkout and build.", "defaultValue": "http:///launchpad.net/mybranch"}, {"name": "TEST_ID", "description": "Testing Element", "defaultValue": "DEFAULT"}], parse_parameters_from_job(new_xml))
def test_add_parameter_to_job(self): """ add_parameter_to_job adds the XML for a JenkinsParameter to a Jenkins job document. """ parameter = JenkinsParameter("TEST_ID", "Testing Element", "DEFAULT") jobtype = JobTypeWithParamsFactory.build() new_xml = add_parameter_to_job(parameter, jobtype.config_xml) self.assertEqual([{ "name": "BUILD_ID", "description": "The projectbuild id to associate with.", "defaultValue": None }, { "name": "BRANCH_TO_CHECKOUT", "description": "Branch to checkout and build.", "defaultValue": "http:///launchpad.net/mybranch" }, { "name": "TEST_ID", "description": "Testing Element", "defaultValue": "DEFAULT" }], parse_parameters_from_job(new_xml))
def get_parameters(self): """ Parse the config_xml and extract the parameters. """ return parse_parameters_from_job(self.config_xml)