From: salimfadhley Date: Wed, 12 Jun 2013 22:00:48 +0000 (+0100) Subject: get the parameterized build unit-test working again X-Git-Tag: v0.2.23~213 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9ebd18badeaf675350835bd0bf139a827bb556c0;p=tools%2Fpython-jenkinsapi.git get the parameterized build unit-test working again --- diff --git a/jenkinsapi/artifact.py b/jenkinsapi/artifact.py index d5e90b0..3153bf5 100644 --- a/jenkinsapi/artifact.py +++ b/jenkinsapi/artifact.py @@ -62,7 +62,7 @@ class Artifact(object): def get_jenkins_obj(self): return self.build.get_jenkins_obj() - def getData(self): + def get_data(self): """ Grab the text of the artifact """ @@ -74,7 +74,7 @@ class Artifact(object): Download the the artifact to a path. """ with open(fspath, "wb") as out: - out.write(self.getData()) + out.write(self.get_data()) return fspath def _verify_download(self, fspath): diff --git a/jenkinsapi/job.py b/jenkinsapi/job.py index 2f8b8ca..9841771 100644 --- a/jenkinsapi/job.py +++ b/jenkinsapi/job.py @@ -114,7 +114,7 @@ class Job(JenkinsBase, MutableJenkinsThing): response = self.jenkins.requester.post_and_confirm_status( url, - data=self.mk_json_from_build_parameters(build_params), # See above - build params have to be JSON encoded & posted. + data={'json':self.mk_json_from_build_parameters(build_params)}, # See above - build params have to be JSON encoded & posted. params=params ) diff --git a/jenkinsapi/utils/requester.py b/jenkinsapi/utils/requester.py index a90a9a8..e4ecd41 100644 --- a/jenkinsapi/utils/requester.py +++ b/jenkinsapi/utils/requester.py @@ -55,7 +55,7 @@ class Requester(object): return self.post_and_confirm_status(url, params, data, headers) def post_and_confirm_status(self, url, params=None, data=None, headers=None): - assert isinstance(data, str) + assert isinstance(data, (str,dict)), "Unexpected data type: %s" % repr(data) if not headers: headers = {'Content-Type': 'application/x-www-form-urlencoded'} diff --git a/jenkinsapi_tests/systests/test_parameterized_builds.py b/jenkinsapi_tests/systests/test_parameterized_builds.py index 5845c93..4009a09 100644 --- a/jenkinsapi_tests/systests/test_parameterized_builds.py +++ b/jenkinsapi_tests/systests/test_parameterized_builds.py @@ -37,18 +37,18 @@ JOB_CONFIG = """ ping -c 1 localhost | tee out.txt -cat $A > a.txt -cat $B > b.txt +echo $A > a.txt +echo $B > b.txt - + * false - false + true @@ -71,8 +71,12 @@ class TestParameterizedBuilds(BaseSystemTest): artifacts = b.get_artifact_dict() self.assertIsInstance(artifacts, dict) - artA = artifacts['A.txt'] - artB = artifacts['B.txt'] + import ipdb + ipdb.set_trace() + + artB = artifacts['b.txt'] + + self.assertTrue(artB.get_data().strip(), param_B) # TODO: Actually verify the download