Commit 24bf3539 authored by Jérome Perrin's avatar Jérome Perrin

HalJsonStyle: py3 (OK py2)

parent 0a638c70
...@@ -16,6 +16,7 @@ from six.moves import cStringIO as StringIO ...@@ -16,6 +16,7 @@ from six.moves import cStringIO as StringIO
import json import json
import re import re
from six.moves.urllib.parse import quote, quote_plus from six.moves.urllib.parse import quote, quote_plus
import six
import mock import mock
from zope.globalrequest import setRequest # pylint: disable=no-name-in-module, import-error from zope.globalrequest import setRequest # pylint: disable=no-name-in-module, import-error
...@@ -1324,7 +1325,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -1324,7 +1325,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
def test_getHateoasDocument_property_corrupted_encoding(self): def test_getHateoasDocument_property_corrupted_encoding(self):
document = self._makeDocument() document = self._makeDocument()
# this sequence of bytes does not encode to UTF-8 # this sequence of bytes does not encode to UTF-8
document.setTitle('\xe9\xcf\xf3\xaf') document.setTitle(b'\xe9\xcf\xf3\xaf')
fake_request = do_fake_request("GET") fake_request = do_fake_request("GET")
result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas(REQUEST=fake_request, mode="traverse", relative_url=document.getRelativeUrl(), view="view") result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas(REQUEST=fake_request, mode="traverse", relative_url=document.getRelativeUrl(), view="view")
self.assertEqual(fake_request.RESPONSE.status, 200) self.assertEqual(fake_request.RESPONSE.status, 200)
...@@ -1682,10 +1683,12 @@ class TestERP5Document_getHateoas_mode_search(ERP5HALJSONStyleSkinsMixin): ...@@ -1682,10 +1683,12 @@ class TestERP5Document_getHateoas_mode_search(ERP5HALJSONStyleSkinsMixin):
def test_getHateoas_default_param_json_param(self): def test_getHateoas_default_param_json_param(self):
fake_request = do_fake_request("GET") fake_request = do_fake_request("GET")
unknown_columns_re = re.escape("Unknown columns ['ê']")
if six.PY2:
unknown_columns_re = "Unknown columns.*\\\\xc3\\\\xaa.*"
self.assertRaisesRegex( self.assertRaisesRegex(
TypeError, TypeError,
# "Unknown columns.*'\\xc3\\xaa'.", unknown_columns_re,
"Unknown columns.*\\\\xc3\\\\xaa.*",
self.portal.web_site_module.hateoas.ERP5Document_getHateoas, self.portal.web_site_module.hateoas.ERP5Document_getHateoas,
REQUEST=fake_request, REQUEST=fake_request,
mode="search", mode="search",
...@@ -1725,7 +1728,7 @@ return context.getPortalObject().foo_module.contentValues() ...@@ -1725,7 +1728,7 @@ return context.getPortalObject().foo_module.contentValues()
form_relative_url='portal_skins/erp5_ui_test/FooModule_viewFooList/listbox' form_relative_url='portal_skins/erp5_ui_test/FooModule_viewFooList/listbox'
) )
result_dict = json.loads(result) result_dict = json.loads(result)
#editalble creation date is defined at proxy form # editable creation date is defined at proxy form
# Test the listbox_uid parameter # Test the listbox_uid parameter
self.assertEqual(result_dict['_embedded']['contents'][0]['listbox_uid:list']['key'], 'listbox_uid:list') self.assertEqual(result_dict['_embedded']['contents'][0]['listbox_uid:list']['key'], 'listbox_uid:list')
self.assertEqual(result_dict['_embedded']['contents'][0]['id']['field_gadget_param']['type'], 'StringField') self.assertEqual(result_dict['_embedded']['contents'][0]['id']['field_gadget_param']['type'], 'StringField')
...@@ -2422,7 +2425,7 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id ...@@ -2422,7 +2425,7 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id
@changeSkin('Hal') @changeSkin('Hal')
def test_getHateoas_property_corrupted_encoding(self, document): def test_getHateoas_property_corrupted_encoding(self, document):
# this sequence of bytes does not encode to UTF-8 # this sequence of bytes does not encode to UTF-8
document.setTitle('\xe9\xcf\xf3\xaf') document.setTitle(b'\xe9\xcf\xf3\xaf')
# self.tic() # self.tic()
fake_request = do_fake_request("GET") fake_request = do_fake_request("GET")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment