Allow use of unicode job names
Closes bug: #1713481 Signed-off-by: Jan Priessnitz <jan.priessnitz@gooddata.com> Change-Id: I8a1ff4bf0f7711ab9c9b76f538411a854244283c
This commit is contained in:
parent
2df5f638d1
commit
44d211b90f
@ -331,7 +331,7 @@ class Jenkins(object):
|
||||
for k, v in params.items():
|
||||
if k in ["name", "msg", "short_name", "from_short_name",
|
||||
"to_short_name", "folder_url", "from_folder_url", "to_folder_url"]:
|
||||
params[k] = quote(v)
|
||||
params[k] = quote(v.encode('utf8'))
|
||||
return params
|
||||
|
||||
def _build_url(self, format_spec, variables=None):
|
||||
@ -341,7 +341,7 @@ class Jenkins(object):
|
||||
else:
|
||||
url_path = format_spec
|
||||
|
||||
return urljoin(self.server, url_path)
|
||||
return str(urljoin(self.server, url_path))
|
||||
|
||||
def maybe_add_crumb(self, req):
|
||||
# We don't know yet whether we need a crumb
|
||||
@ -562,11 +562,12 @@ class Jenkins(object):
|
||||
# Jenkins's funky authentication means its nigh impossible to
|
||||
# distinguish errors.
|
||||
if e.response.status_code in [401, 403, 500]:
|
||||
raise JenkinsException(
|
||||
'Error in request. ' +
|
||||
'Possibly authentication failed [%s]: %s' % (
|
||||
e.response.status_code, e.response.reason)
|
||||
)
|
||||
msg = 'Error in request. ' + \
|
||||
'Possibly authentication failed [%s]: %s' % (
|
||||
e.response.status_code, e.response.reason)
|
||||
if e.response.text:
|
||||
msg += '\n' + e.response.text
|
||||
raise JenkinsException(msg)
|
||||
elif e.response.status_code == 404:
|
||||
raise NotFoundException('Requested item could not be found')
|
||||
else:
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from mock import patch
|
||||
|
||||
from six.moves.urllib.parse import quote
|
||||
from tests.helper import build_response_mock
|
||||
from tests.jobs.base import JenkinsJobsTestBase
|
||||
|
||||
@ -11,10 +13,10 @@ class JenkinsBuildJobTest(JenkinsJobsTestBase):
|
||||
session_send_mock.return_value = build_response_mock(
|
||||
302, {}, headers={'Location': self.make_url('/queue/item/25/')})
|
||||
|
||||
queue_id = self.j.build_job(u'Test Job')
|
||||
queue_id = self.j.build_job(u'Test Jøb')
|
||||
|
||||
self.assertEqual(session_send_mock.call_args[0][1].url,
|
||||
self.make_url('job/Test%20Job/build'))
|
||||
self.make_url(quote(u'job/Test Jøb/build'.encode('utf8'))))
|
||||
self.assertEqual(queue_id, 25)
|
||||
|
||||
@patch('jenkins.requests.Session.send', autospec=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user