dpark: use only unicode strings (#38130)

This commit is contained in:
Nicolas Roche 2019-12-19 15:57:27 +01:00 committed by Benjamin Dauvergne
parent 3db9ac410f
commit 821cc2136a
2 changed files with 11 additions and 0 deletions

View File

@ -14,6 +14,8 @@
# 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/>.
from __future__ import unicode_literals
import base64
import json

View File

@ -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):