Fixes for this bug.

This commit is contained in:
Kevin McDermott 2012-05-17 16:10:00 +01:00
parent a64d11bd47
commit 08f41aa93f
5 changed files with 30 additions and 2 deletions

2
Makefile Normal file
View File

@ -0,0 +1,2 @@
test:
python -m unittest discover

View File

@ -336,8 +336,9 @@ class Jenkins(object):
:param name: Name of Jenkins job, ``str``
:returns: job configuration (XML format)
'''
get_config_url = self.server + CONFIG_JOB%locals()
return self.jenkins_open(urllib2.Request(get_config_url))
request = urllib2.Request(self.server + CONFIG_JOB %
{"name": urllib.quote(name)})
return self.jenkins_open(request)
def reconfig_job(self, name, config_xml):
'''

0
tests/__init__.py Normal file
View File

5
tests/helper.py Normal file
View File

@ -0,0 +1,5 @@
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
import jenkins

20
tests/test_jenkins.py Normal file
View File

@ -0,0 +1,20 @@
import unittest
import urllib2
from mock import patch, call
from helper import jenkins
class JenkinsTest(unittest.TestCase):
@patch.object(jenkins.Jenkins, 'jenkins_open')
def test_get_job_config_encodes_job_name(self, jenkins_mock):
"""
The job name parameter specified should be urlencoded properly.
"""
j = jenkins.Jenkins('http://example.com/', 'test', 'test')
j.get_job_config(u'Test Job')
self.assertEqual(jenkins_mock.call_args[0][0].get_full_url(),
u'http://example.com/job/Test%20Job/config.xml')