python-jenkins-developers team mailing list archive
-
python-jenkins-developers team
-
Mailing list archive
-
Message #00040
[Merge] lp:~bigkevmcd/python-jenkins/fix-bug-1000799-urlquote into lp:python-jenkins
Kevin McDermott has proposed merging lp:~bigkevmcd/python-jenkins/fix-bug-1000799-urlquote into lp:python-jenkins.
Requested reviews:
Python Jenkins Developers (python-jenkins-developers)
Related bugs:
Bug #1000799 in Python Jenkins: "Doesn't handle job names with spaces"
https://bugs.launchpad.net/python-jenkins/+bug/1000799
For more details, see:
https://code.launchpad.net/~bigkevmcd/python-jenkins/fix-bug-1000799-urlquote/+merge/106206
I've added some test infrastructure, and am happy to fix the other methods which suffer from the same problem prior to merging, if this approach is of interest.
--
https://code.launchpad.net/~bigkevmcd/python-jenkins/fix-bug-1000799-urlquote/+merge/106206
Your team Python Jenkins Developers is requested to review the proposed merge of lp:~bigkevmcd/python-jenkins/fix-bug-1000799-urlquote into lp:python-jenkins.
=== added file 'Makefile'
--- Makefile 1970-01-01 00:00:00 +0000
+++ Makefile 2012-05-17 15:16:16 +0000
@@ -0,0 +1,2 @@
+test:
+ python -m unittest discover
=== modified file 'jenkins/__init__.py'
--- jenkins/__init__.py 2012-03-02 16:26:13 +0000
+++ jenkins/__init__.py 2012-05-17 15:16:16 +0000
@@ -336,8 +336,9 @@
: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):
'''
=== added directory 'tests'
=== added file 'tests/__init__.py'
=== added file 'tests/helper.py'
--- tests/helper.py 1970-01-01 00:00:00 +0000
+++ tests/helper.py 2012-05-17 15:16:16 +0000
@@ -0,0 +1,5 @@
+import os
+import sys
+sys.path.insert(0, os.path.abspath('..'))
+
+import jenkins
=== added file 'tests/test_jenkins.py'
--- tests/test_jenkins.py 1970-01-01 00:00:00 +0000
+++ tests/test_jenkins.py 2012-05-17 15:16:16 +0000
@@ -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')
Follow ups