Merge lp:~bigkevmcd/python-jenkins/fix-bug-1000799-urlquote into lp:~python-jenkins-developers/python-jenkins/trunk

Proposed by Kevin McDermott
Status: Merged
Merged at revision: 15
Proposed branch: lp:~bigkevmcd/python-jenkins/fix-bug-1000799-urlquote
Merge into: lp:~python-jenkins-developers/python-jenkins/trunk
Diff against target: 58 lines (+29/-2)
4 files modified
Makefile (+2/-0)
jenkins/__init__.py (+3/-2)
tests/helper.py (+5/-0)
tests/test_jenkins.py (+19/-0)
To merge this branch: bzr merge lp:~bigkevmcd/python-jenkins/fix-bug-1000799-urlquote
Reviewer Review Type Date Requested Status
James Page Pending
Review via email: mp+106206@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Kevin McDermott (bigkevmcd) wrote :

I should add, this requires the "mock" library for Python, which is available on Pypi, and is standard from Python 3.3.

15. By Kevin McDermott

Some extraneous imports.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'Makefile'
2--- Makefile 1970-01-01 00:00:00 +0000
3+++ Makefile 2012-05-17 15:28:17 +0000
4@@ -0,0 +1,2 @@
5+test:
6+ python -m unittest discover
7
8=== modified file 'jenkins/__init__.py'
9--- jenkins/__init__.py 2012-03-02 16:26:13 +0000
10+++ jenkins/__init__.py 2012-05-17 15:28:17 +0000
11@@ -336,8 +336,9 @@
12 :param name: Name of Jenkins job, ``str``
13 :returns: job configuration (XML format)
14 '''
15- get_config_url = self.server + CONFIG_JOB%locals()
16- return self.jenkins_open(urllib2.Request(get_config_url))
17+ request = urllib2.Request(self.server + CONFIG_JOB %
18+ {"name": urllib.quote(name)})
19+ return self.jenkins_open(request)
20
21 def reconfig_job(self, name, config_xml):
22 '''
23
24=== added directory 'tests'
25=== added file 'tests/__init__.py'
26=== added file 'tests/helper.py'
27--- tests/helper.py 1970-01-01 00:00:00 +0000
28+++ tests/helper.py 2012-05-17 15:28:17 +0000
29@@ -0,0 +1,5 @@
30+import os
31+import sys
32+sys.path.insert(0, os.path.abspath('..'))
33+
34+import jenkins
35
36=== added file 'tests/test_jenkins.py'
37--- tests/test_jenkins.py 1970-01-01 00:00:00 +0000
38+++ tests/test_jenkins.py 2012-05-17 15:28:17 +0000
39@@ -0,0 +1,19 @@
40+import unittest
41+
42+from mock import patch
43+
44+from helper import jenkins
45+
46+
47+class JenkinsTest(unittest.TestCase):
48+
49+ @patch.object(jenkins.Jenkins, 'jenkins_open')
50+ def test_get_job_config_encodes_job_name(self, jenkins_mock):
51+ """
52+ The job name parameter specified should be urlencoded properly.
53+ """
54+ j = jenkins.Jenkins('http://example.com/', 'test', 'test')
55+ j.get_job_config(u'Test Job')
56+
57+ self.assertEqual(jenkins_mock.call_args[0][0].get_full_url(),
58+ u'http://example.com/job/Test%20Job/config.xml')

Subscribers

People subscribed via source and target branches