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():
|
for k, v in params.items():
|
||||||
if k in ["name", "msg", "short_name", "from_short_name",
|
if k in ["name", "msg", "short_name", "from_short_name",
|
||||||
"to_short_name", "folder_url", "from_folder_url", "to_folder_url"]:
|
"to_short_name", "folder_url", "from_folder_url", "to_folder_url"]:
|
||||||
params[k] = quote(v)
|
params[k] = quote(v.encode('utf8'))
|
||||||
return params
|
return params
|
||||||
|
|
||||||
def _build_url(self, format_spec, variables=None):
|
def _build_url(self, format_spec, variables=None):
|
||||||
@ -341,7 +341,7 @@ class Jenkins(object):
|
|||||||
else:
|
else:
|
||||||
url_path = format_spec
|
url_path = format_spec
|
||||||
|
|
||||||
return urljoin(self.server, url_path)
|
return str(urljoin(self.server, url_path))
|
||||||
|
|
||||||
def maybe_add_crumb(self, req):
|
def maybe_add_crumb(self, req):
|
||||||
# We don't know yet whether we need a crumb
|
# 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
|
# Jenkins's funky authentication means its nigh impossible to
|
||||||
# distinguish errors.
|
# distinguish errors.
|
||||||
if e.response.status_code in [401, 403, 500]:
|
if e.response.status_code in [401, 403, 500]:
|
||||||
raise JenkinsException(
|
msg = 'Error in request. ' + \
|
||||||
'Error in request. ' +
|
|
||||||
'Possibly authentication failed [%s]: %s' % (
|
'Possibly authentication failed [%s]: %s' % (
|
||||||
e.response.status_code, e.response.reason)
|
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:
|
elif e.response.status_code == 404:
|
||||||
raise NotFoundException('Requested item could not be found')
|
raise NotFoundException('Requested item could not be found')
|
||||||
else:
|
else:
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
from mock import patch
|
from mock import patch
|
||||||
|
|
||||||
|
from six.moves.urllib.parse import quote
|
||||||
from tests.helper import build_response_mock
|
from tests.helper import build_response_mock
|
||||||
from tests.jobs.base import JenkinsJobsTestBase
|
from tests.jobs.base import JenkinsJobsTestBase
|
||||||
|
|
||||||
@ -11,10 +13,10 @@ class JenkinsBuildJobTest(JenkinsJobsTestBase):
|
|||||||
session_send_mock.return_value = build_response_mock(
|
session_send_mock.return_value = build_response_mock(
|
||||||
302, {}, headers={'Location': self.make_url('/queue/item/25/')})
|
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.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)
|
self.assertEqual(queue_id, 25)
|
||||||
|
|
||||||
@patch('jenkins.requests.Session.send', autospec=True)
|
@patch('jenkins.requests.Session.send', autospec=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user