From 19694e1a47ee1082876cc37b5e400bd05309a3f5 Mon Sep 17 00:00:00 2001 From: Nicolas ROCHE Date: Thu, 19 Dec 2019 15:57:27 +0100 Subject: [PATCH] dpark: use only unicode strings (#38130) --- passerelle/contrib/dpark/models.py | 2 ++ tests/test_dpark.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/passerelle/contrib/dpark/models.py b/passerelle/contrib/dpark/models.py index 0e4818b8..cec289a7 100644 --- a/passerelle/contrib/dpark/models.py +++ b/passerelle/contrib/dpark/models.py @@ -14,6 +14,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from __future__ import unicode_literals + import base64 import json diff --git a/tests/test_dpark.py b/tests/test_dpark.py index d507032c..b07e78ee 100644 --- a/tests/test_dpark.py +++ b/tests/test_dpark.py @@ -78,6 +78,10 @@ class ReplyDataClass(dict): super(ReplyDataClass, self).__init__(**kwargs) +class WebFaultHavingLatin1(WebFault): + pass + + class MockedService(object): 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) elif self.error_class is TransportError: raise self.error_class('connection error occured', None) + elif self.error_class is WebFaultHavingLatin1: + raise WebFault(message=u'éêè') else: raise Exception('random error') @@ -121,6 +127,9 @@ def test_call_service_error(dpark, app): client.return_value = get_client(error_class=Exception) resp = app.get('/dpark/test/ping/') 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): -- 2.24.0