dpark: use only unicode strings (#38130)
This commit is contained in:
parent
3db9ac410f
commit
821cc2136a
|
@ -14,6 +14,8 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,10 @@ class ReplyDataClass(dict):
|
||||||
super(ReplyDataClass, self).__init__(**kwargs)
|
super(ReplyDataClass, self).__init__(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class WebFaultHavingLatin1(WebFault):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class MockedService(object):
|
class MockedService(object):
|
||||||
|
|
||||||
def __init__(self, success, error_class, replydata):
|
def __init__(self, success, error_class, replydata):
|
||||||
|
@ -90,6 +94,8 @@ class MockedService(object):
|
||||||
raise self.error_class(mock.Mock(faulstring='Error %s raised' % self.error_class.__name__), None)
|
raise self.error_class(mock.Mock(faulstring='Error %s raised' % self.error_class.__name__), None)
|
||||||
elif self.error_class is TransportError:
|
elif self.error_class is TransportError:
|
||||||
raise self.error_class('connection error occured', None)
|
raise self.error_class('connection error occured', None)
|
||||||
|
elif self.error_class is WebFaultHavingLatin1:
|
||||||
|
raise WebFault(message=u'éêè')
|
||||||
else:
|
else:
|
||||||
raise Exception('random error')
|
raise Exception('random error')
|
||||||
|
|
||||||
|
@ -121,6 +127,9 @@ def test_call_service_error(dpark, app):
|
||||||
client.return_value = get_client(error_class=Exception)
|
client.return_value = get_client(error_class=Exception)
|
||||||
resp = app.get('/dpark/test/ping/')
|
resp = app.get('/dpark/test/ping/')
|
||||||
assert 'Error: random error' in resp.json['err_desc']
|
assert 'Error: random error' in resp.json['err_desc']
|
||||||
|
client.return_value = get_client(error_class=WebFaultHavingLatin1)
|
||||||
|
resp = app.get('/dpark/test/ping/')
|
||||||
|
assert u'ServiceError: éêè' in resp.json['err_desc']
|
||||||
|
|
||||||
|
|
||||||
def test_ping(dpark, app):
|
def test_ping(dpark, app):
|
||||||
|
|
Loading…
Reference in New Issue