Merge "fix for python 3, decode job output"

This commit is contained in:
Jenkins 2015-10-14 23:06:25 +00:00 committed by Gerrit Code Review
commit 46bc9ecab5
2 changed files with 22 additions and 1 deletions

View File

@ -352,7 +352,7 @@ class Builder(object):
self.cache.set(job.name, old_md5)
if self.cache.has_changed(job.name, md5) or self.ignore_cache:
self.jenkins.update_job(job.name, job.output())
self.jenkins.update_job(job.name, job.output().decode('utf-8'))
updated_jobs += 1
self.cache.set(job.name, md5)
else:

View File

@ -15,6 +15,7 @@
# under the License.
import os
import six
from jenkins_jobs import cmd
from jenkins_jobs import builder
@ -39,6 +40,26 @@ class UpdateTests(CmdTestsBase):
cmd.execute(args, self.config)
update_job_mock.assert_called_with([path], [])
@mock.patch('jenkins_jobs.builder.Jenkins.is_job', return_value=True)
@mock.patch('jenkins_jobs.builder.Jenkins.get_jobs')
@mock.patch('jenkins_jobs.builder.Jenkins.get_job_md5')
@mock.patch('jenkins_jobs.builder.Jenkins.update_job')
def test_update_jobs_decode_job_output(self, update_job_mock,
get_job_md5_mock, get_jobs_mock,
is_job_mock):
"""
Test that job xml output has been decoded before attempting to update
"""
# don't care about the value returned here
update_job_mock.return_value = ([], 0)
path = os.path.join(self.fixtures_path, 'cmd-002.yaml')
args = self.parser.parse_args(['update', path])
cmd.execute(args, self.config)
self.assertTrue(isinstance(update_job_mock.call_args[0][1],
six.text_type))
@mock.patch('jenkins_jobs.builder.Jenkins.is_job', return_value=True)
@mock.patch('jenkins_jobs.builder.Jenkins.get_jobs')
@mock.patch('jenkins_jobs.builder.Builder.delete_job')