Commit bd74c630 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

py2/py3: make erp5_hal_json_style compatible with Python 3.

parent 7217673a
...@@ -15,16 +15,17 @@ There are runtime values hidden in every dialog form (injected by getHateoas Scr ...@@ -15,16 +15,17 @@ There are runtime values hidden in every dialog form (injected by getHateoas Scr
from erp5.component.module.Log import log, WARNING from erp5.component.module.Log import log, WARNING
from Products.Formulator.Errors import FormValidationError from Products.Formulator.Errors import FormValidationError
import json import json
import six
# http://stackoverflow.com/a/13105359 # http://stackoverflow.com/a/13105359
def byteify(value): def byteify(value):
if isinstance(value, dict): if isinstance(value, dict):
return {byteify(key): byteify(value) for key, value in value.iteritems()} return {byteify(key): byteify(value) for key, value in six.iteritems(value)}
elif isinstance(value, list): elif isinstance(value, list):
return [byteify(element) for element in value] return [byteify(element) for element in value]
elif isinstance(value, tuple): elif isinstance(value, tuple):
return tuple(byteify(element) for element in value) return tuple(byteify(element) for element in value)
elif isinstance(value, unicode): elif six.PY2 and isinstance(value, six.text_type):
return value.encode('utf-8') return value.encode('utf-8')
else: else:
return value return value
......
...@@ -6,8 +6,9 @@ Return JSON with message to be displayed and set according HTTP STATUS for messa ...@@ -6,8 +6,9 @@ Return JSON with message to be displayed and set according HTTP STATUS for messa
""" """
import json import json
from erp5.component.module.Log import WARNING, ERROR from erp5.component.module.Log import WARNING, ERROR
import six
if isinstance(level, (str, unicode)): if isinstance(level, (str, six.text_type)):
if level.lower() == "error": if level.lower() == "error":
response_code = 500 response_code = 500
elif level.lower().startswith("warn"): elif level.lower().startswith("warn"):
......
...@@ -49,7 +49,7 @@ When handling form, we can expect field values to be stored in REQUEST.form in t ...@@ -49,7 +49,7 @@ When handling form, we can expect field values to be stored in REQUEST.form in t
from ZTUtils import make_query from ZTUtils import make_query
import json import json
import urllib from six.moves.urllib.parse import urlencode
from base64 import urlsafe_b64encode, urlsafe_b64decode from base64 import urlsafe_b64encode, urlsafe_b64decode
from DateTime import DateTime from DateTime import DateTime
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
...@@ -63,6 +63,7 @@ from Products.ERP5Type.Message import Message ...@@ -63,6 +63,7 @@ from Products.ERP5Type.Message import Message
from collections import OrderedDict from collections import OrderedDict
from Products.ERP5Form.Selection import Selection from Products.ERP5Form.Selection import Selection
from Products.PythonScripts.standard import Object from Products.PythonScripts.standard import Object
from Products.ERP5Type.Utils import bytes2str, ensure_list, str2bytes
import six import six
...@@ -84,7 +85,7 @@ def toBasicTypes(obj): ...@@ -84,7 +85,7 @@ def toBasicTypes(obj):
"""Ensure that obj contains only basic types.""" """Ensure that obj contains only basic types."""
if obj is None: if obj is None:
return obj return obj
if isinstance(obj, (bool, float, str) + six.integer_types + six.text_type): if isinstance(obj, (bool, float, str) + six.integer_types + (six.text_type,)):
return obj return obj
if isinstance(obj, list): if isinstance(obj, list):
return [toBasicTypes(x) for x in obj] return [toBasicTypes(x) for x in obj]
...@@ -125,12 +126,12 @@ def renderHiddenField(form, name, value): ...@@ -125,12 +126,12 @@ def renderHiddenField(form, name, value):
# http://stackoverflow.com/a/13105359 # http://stackoverflow.com/a/13105359
def byteify(string): def byteify(string):
if isinstance(string, dict): if isinstance(string, dict):
return {byteify(key): byteify(value) for key, value in string.iteritems()} return {byteify(key): byteify(value) for key, value in six.iteritems(string)}
elif isinstance(string, list): elif isinstance(string, list):
return [byteify(element) for element in string] return [byteify(element) for element in string]
elif isinstance(string, tuple): elif isinstance(string, tuple):
return tuple(byteify(element) for element in string) return tuple(byteify(element) for element in string)
elif isinstance(string, unicode): elif six.PY2 and isinstance(string, six.text_type):
return string.encode('utf-8') return string.encode('utf-8')
else: else:
return string return string
...@@ -140,10 +141,11 @@ def ensureUTF8(obj): ...@@ -140,10 +141,11 @@ def ensureUTF8(obj):
"""Make sure string is UTF-8, by replacing characters that """Make sure string is UTF-8, by replacing characters that
cannot be decoded. cannot be decoded.
""" """
if isinstance(obj, str): if six.PY2:
return obj.decode('utf-8', 'replace').encode('utf-8') if isinstance(obj, str):
elif isinstance(obj, unicode): return obj.decode('utf-8', 'replace').encode('utf-8')
return obj.encode('utf-8', 'replace') elif isinstance(obj, six.text_type):
return obj.encode('utf-8', 'replace')
return obj return obj
def ensureSerializable(obj): def ensureSerializable(obj):
...@@ -422,8 +424,8 @@ def getFieldDefault(form, field, key, value=MARKER): ...@@ -422,8 +424,8 @@ def getFieldDefault(form, field, key, value=MARKER):
if value is MARKER: if value is MARKER:
# use marker because default value can be intentionally empty string # use marker because default value can be intentionally empty string
value = field.get_value('default', request=REQUEST, REQUEST=REQUEST) value = field.get_value('default', request=REQUEST, REQUEST=REQUEST)
if field.has_value("unicode") and field.get_value("unicode") and isinstance(value, unicode): if six.PY2 and field.has_value("unicode") and field.get_value("unicode") and isinstance(value, six.text_type):
value = unicode(value, form.get_form_encoding()) value = value.decode(form.get_form_encoding())
if getattr(value, 'translate', None) is not None: if getattr(value, 'translate', None) is not None:
return "%s" % value return "%s" % value
return value return value
...@@ -471,7 +473,7 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None, ...@@ -471,7 +473,7 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None,
selected_language = erp5_ui.get_selected_language() selected_language = erp5_ui.get_selected_language()
result["translate_title_href"] = '%s/manage_messages?%s' % ( result["translate_title_href"] = '%s/manage_messages?%s' % (
'/'.join(erp5_ui.getPhysicalPath()[2:]), '/'.join(erp5_ui.getPhysicalPath()[2:]),
urllib.urlencode({"regex": "^%s$" % field.title(), urlencode({"regex": "^%s$" % field.title(),
"lang": selected_language}) "lang": selected_language})
) )
...@@ -479,7 +481,7 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None, ...@@ -479,7 +481,7 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None,
if field_description: if field_description:
result["translate_description_href"] = '%s/manage_messages?%s' % ( result["translate_description_href"] = '%s/manage_messages?%s' % (
'/'.join(erp5_ui.getPhysicalPath()[2:]), '/'.join(erp5_ui.getPhysicalPath()[2:]),
urllib.urlencode({"regex": "^%s$" % field_description, urlencode({"regex": "^%s$" % field_description,
"lang": selected_language}) "lang": selected_language})
) )
...@@ -661,11 +663,11 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None, ...@@ -661,11 +663,11 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None,
"script_id": script.id, "script_id": script.id,
"relative_url": getRealRelativeUrl(traversed_document).replace("/", "%2F"), "relative_url": getRealRelativeUrl(traversed_document).replace("/", "%2F"),
"view": "Base_viewRelatedObjectList", "view": "Base_viewRelatedObjectList",
"extra_param_json": urlsafe_b64encode( "extra_param_json": bytes2str(urlsafe_b64encode(str2bytes(
json.dumps(ensureSerializable({ json.dumps(ensureSerializable({
'original_form_id': form.id, 'original_form_id': form.id,
'field_id': field.id 'field_id': field.id
}))) })))))
} }
}) })
...@@ -714,7 +716,7 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None, ...@@ -714,7 +716,7 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None,
or field.get_value("editable_columns"))] or field.get_value("editable_columns"))]
all_column_list = [(name, title) for name, title in field.get_value("all_columns")] all_column_list = [(name, title) for name, title in field.get_value("all_columns")]
catalog_column_list = [(name, title) catalog_column_list = [(name, title)
for name, title in OrderedDict(column_list + all_column_list).items() for name, title in ensure_list(OrderedDict(column_list + all_column_list).items())
if sql_catalog.isValidColumn(name)] if sql_catalog.isValidColumn(name)]
# try to get specified searchable columns and fail back to all searchable columns # try to get specified searchable columns and fail back to all searchable columns
...@@ -786,10 +788,10 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None, ...@@ -786,10 +788,10 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None,
"relative_url": getRealRelativeUrl(traversed_document).replace("/", "%2F"), "relative_url": getRealRelativeUrl(traversed_document).replace("/", "%2F"),
"form_relative_url": "%s/%s" % (form_relative_url, field.id), "form_relative_url": "%s/%s" % (form_relative_url, field.id),
"list_method": list_method_name, "list_method": list_method_name,
"default_param_json": urlsafe_b64encode( "default_param_json": bytes2str(urlsafe_b64encode(str2bytes(
json.dumps(ensureSerializable(list_method_query_dict))), json.dumps(ensureSerializable(list_method_query_dict))))),
"extra_param_json": urlsafe_b64encode( "extra_param_json": bytes2str(urlsafe_b64encode(str2bytes(
json.dumps(ensureSerializable(extra_param_dict))) json.dumps(ensureSerializable(extra_param_dict)))))
} }
# once we imprint `default_params` into query string of 'list method' we # once we imprint `default_params` into query string of 'list method' we
# don't want them to propagate to the query as well # don't want them to propagate to the query as well
...@@ -808,7 +810,7 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None, ...@@ -808,7 +810,7 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None,
"script_id": script.id, "script_id": script.id,
"relative_url": traversed_document.getRelativeUrl().replace("/", "%2F"), "relative_url": traversed_document.getRelativeUrl().replace("/", "%2F"),
"list_method": list_method_name, "list_method": list_method_name,
"default_param_json": urlsafe_b64encode(json.dumps(ensureSerializable(list_method_query_dict))) "default_param_json": bytes2str(urlsafe_b64encode(str2bytes(json.dumps(ensureSerializable(list_method_query_dict)))))
} }
list_method_query_dict = {} list_method_query_dict = {}
""" """
...@@ -1052,12 +1054,12 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti ...@@ -1052,12 +1054,12 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti
"script_id": script.id, "script_id": script.id,
"relative_url": getRealRelativeUrl(traversed_document).replace("/", "%2F"), "relative_url": getRealRelativeUrl(traversed_document).replace("/", "%2F"),
"view": "Base_viewRelatedObjectList", "view": "Base_viewRelatedObjectList",
"extra_param_json": urlsafe_b64encode( "extra_param_json": bytes2str(urlsafe_b64encode(str2bytes(
json.dumps(ensureSerializable({ json.dumps(ensureSerializable({
'proxy_listbox_id': x, 'proxy_listbox_id': x,
'original_form_id': extra_param_json['original_form_id'], 'original_form_id': extra_param_json['original_form_id'],
'field_id': extra_param_json['field_id'] 'field_id': extra_param_json['field_id']
}))) })))))
}) for x, y in proxy_form_id_list], }) for x, y in proxy_form_id_list],
"first_item": 1, "first_item": 1,
"required": 0, "required": 0,
...@@ -1075,12 +1077,12 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti ...@@ -1075,12 +1077,12 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti
"script_id": script.id, "script_id": script.id,
"relative_url": getRealRelativeUrl(traversed_document).replace("/", "%2F"), "relative_url": getRealRelativeUrl(traversed_document).replace("/", "%2F"),
"view": "Base_viewRelatedObjectList", "view": "Base_viewRelatedObjectList",
"extra_param_json": urlsafe_b64encode( "extra_param_json": bytes2str(urlsafe_b64encode(str2bytes(
json.dumps(ensureSerializable({ json.dumps(ensureSerializable({
'proxy_listbox_id': REQUEST.get('proxy_listbox_id', None), 'proxy_listbox_id': REQUEST.get('proxy_listbox_id', None),
'original_form_id': extra_param_json['original_form_id'], 'original_form_id': extra_param_json['original_form_id'],
'field_id': extra_param_json['field_id'] 'field_id': extra_param_json['field_id']
}))) })))))
} }
# Go through all groups ("left", "bottom", "hidden" etc.) and add fields from # Go through all groups ("left", "bottom", "hidden" etc.) and add fields from
...@@ -1278,7 +1280,7 @@ def renderFormDefinition(form, response_dict): ...@@ -1278,7 +1280,7 @@ def renderFormDefinition(form, response_dict):
def statusLevelToString(level): def statusLevelToString(level):
"""Transform any level format to lowercase string representation""" """Transform any level format to lowercase string representation"""
if isinstance(level, (str, unicode)): if isinstance(level, (str, six.text_type)):
if level.lower() == "error": if level.lower() == "error":
return "error" return "error"
elif level.lower().startswith("warn"): elif level.lower().startswith("warn"):
...@@ -1579,7 +1581,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None, ...@@ -1579,7 +1581,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
"script_id": script.id, # this script (ERP5Document_getHateoas) "script_id": script.id, # this script (ERP5Document_getHateoas)
"relative_url": getRealRelativeUrl(traversed_document).replace("/", "%2F"), "relative_url": getRealRelativeUrl(traversed_document).replace("/", "%2F"),
"view": erp5_action_list[-1]['name'], "view": erp5_action_list[-1]['name'],
"extra_param_json": urlsafe_b64encode(json.dumps(ensureSerializable(extra_param_json))) "extra_param_json": bytes2str(urlsafe_b64encode(str2bytes(json.dumps(ensureSerializable(extra_param_json)))))
} }
if erp5_action_list: if erp5_action_list:
...@@ -1733,7 +1735,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None, ...@@ -1733,7 +1735,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
# Those parameter will be send back during the listbox submission # Those parameter will be send back during the listbox submission
# to ensure fetching the same lines # to ensure fetching the same lines
listbox_query_param_json = urlsafe_b64encode(json.dumps(ensureSerializable({ listbox_query_param_json = bytes2str(urlsafe_b64encode(str2bytes(json.dumps(ensureSerializable({
'form_relative_url': form_relative_url, 'form_relative_url': form_relative_url,
'list_method': list_method, 'list_method': list_method,
'default_param_json': default_param_json, 'default_param_json': default_param_json,
...@@ -1746,7 +1748,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None, ...@@ -1746,7 +1748,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
'relative_url': relative_url, 'relative_url': relative_url,
'group_by': group_by, 'group_by': group_by,
'sort_on': sort_on 'sort_on': sort_on
}))) })))))
# set 'here' for field rendering which contain TALES expressions # set 'here' for field rendering which contain TALES expressions
REQUEST.set('here', traversed_document) REQUEST.set('here', traversed_document)
...@@ -1920,7 +1922,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None, ...@@ -1920,7 +1922,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
column_list = [(name, title) for name, title in source_field.get_value("columns") if name in select_list] column_list = [(name, title) for name, title in source_field.get_value("columns") if name in select_list]
all_column_list = [(name, title) for name, title in source_field.get_value("all_columns") if name in select_list] all_column_list = [(name, title) for name, title in source_field.get_value("all_columns") if name in select_list]
selection_kw['columns'] = [(name, title) selection_kw['columns'] = [(name, title)
for name, title in OrderedDict(column_list + all_column_list).items()] for name, title in ensure_list(OrderedDict(column_list + all_column_list).items())]
else: else:
selection_kw['columns'] = [] selection_kw['columns'] = []
...@@ -2192,8 +2194,8 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None, ...@@ -2192,8 +2194,8 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
"script_id": script.id, "script_id": script.id,
"relative_url": url_parameter_dict['view_kw']['jio_key'].replace("/", "%2F"), "relative_url": url_parameter_dict['view_kw']['jio_key'].replace("/", "%2F"),
"view": url_parameter_dict['view_kw']['view'], "view": url_parameter_dict['view_kw']['view'],
"extra_param_json": urlsafe_b64encode( "extra_param_json": bytes2str(urlsafe_b64encode(str2bytes(
json.dumps(ensureSerializable(extra_url_param_dict))) json.dumps(ensureSerializable(extra_url_param_dict)))))
} }
# endfor select # endfor select
...@@ -2410,8 +2412,8 @@ if mode == 'url_generator': ...@@ -2410,8 +2412,8 @@ if mode == 'url_generator':
keep_items_json = None keep_items_json = None
else: else:
generator_key = 'traverse_generator_action' generator_key = 'traverse_generator_action'
keep_items_json = urlsafe_b64encode( keep_items_json = bytes2str(urlsafe_b64encode(str2bytes(
json.dumps(ensureSerializable(keep_items))) json.dumps(ensureSerializable(keep_items)))))
return url_template_dict[generator_key] % { return url_template_dict[generator_key] % {
"root_url": site_root.absolute_url(), "root_url": site_root.absolute_url(),
"script_id": 'ERP5Document_getHateoas', "script_id": 'ERP5Document_getHateoas',
......
...@@ -3,6 +3,7 @@ from Products.Formulator.Errors import FormValidationError ...@@ -3,6 +3,7 @@ from Products.Formulator.Errors import FormValidationError
from Products.ERP5Type.Core.Workflow import ValidationFailed from Products.ERP5Type.Core.Workflow import ValidationFailed
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
from erp5.component.module.Log import WARNING from erp5.component.module.Log import WARNING
import six
portal = context.getPortalObject() portal = context.getPortalObject()
request = REQUEST or context.REQUEST request = REQUEST or context.REQUEST
...@@ -43,7 +44,7 @@ for f in form.get_fields(): ...@@ -43,7 +44,7 @@ for f in form.get_fields():
listbox = request.get('listbox') # XXX: hardcoded field name listbox = request.get('listbox') # XXX: hardcoded field name
if listbox is not None: if listbox is not None:
listbox_line_list = [] listbox_line_list = []
for key, value in sorted(listbox.iteritems()): for key, value in sorted(six.iteritems(listbox)):
value['listbox_key'] = key value['listbox_key'] = key
listbox_line_list.append(value) listbox_line_list.append(value)
doaction_param_list['listbox'] = tuple(listbox_line_list) doaction_param_list['listbox'] = tuple(listbox_line_list)
......
...@@ -14,12 +14,13 @@ import DateTime ...@@ -14,12 +14,13 @@ import DateTime
from six.moves import cStringIO as StringIO from six.moves import cStringIO as StringIO
import json import json
import re import re
import urllib from six.moves.urllib.parse import quote, quote_plus
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
from Acquisition import aq_base from Acquisition import aq_base
from Products.ERP5Form.Selection import Selection, DomainSelection from Products.ERP5Form.Selection import Selection, DomainSelection
from Products.ERP5Type.Utils import ensure_list, str2unicode, unicode2str
def changeSkin(skin_name): def changeSkin(skin_name):
...@@ -122,7 +123,7 @@ def do_fake_request(request_method, headers=None, data=()): ...@@ -122,7 +123,7 @@ def do_fake_request(request_method, headers=None, data=()):
if data and request_method.upper() == 'GET': if data and request_method.upper() == 'GET':
# see: GET http://www.cgi101.com/book/ch3/text.html # see: GET http://www.cgi101.com/book/ch3/text.html
env['QUERY_STRING'] = '&'.join( env['QUERY_STRING'] = '&'.join(
'{}={}'.format(urllib.quote_plus(key), urllib.quote(value)) '{}={}'.format(quote_plus(key), quote(value))
for key, value in data for key, value in data
) )
...@@ -131,7 +132,7 @@ def do_fake_request(request_method, headers=None, data=()): ...@@ -131,7 +132,7 @@ def do_fake_request(request_method, headers=None, data=()):
env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded' env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
for key, value in data: for key, value in data:
body_stream.write('{}={!s}&'.format( body_stream.write('{}={!s}&'.format(
urllib.quote_plus(key), urllib.quote(value))) quote_plus(key), quote(value)))
request = HTTPRequest(body_stream, env, HTTPResponse()) request = HTTPRequest(body_stream, env, HTTPResponse())
if data and request_method.upper() == 'POST': if data and request_method.upper() == 'POST':
...@@ -345,21 +346,21 @@ class TestERP5Document_getHateoas_mode_root(ERP5HALJSONStyleSkinsMixin): ...@@ -345,21 +346,21 @@ class TestERP5Document_getHateoas_mode_root(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['view'][0]['href'], self.assertEqual(result_dict['_links']['view'][0]['href'],
"%s/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % ( "%s/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['view'][0]['title'], "View") self.assertEqual(result_dict['_links']['view'][0]['title'], "View")
self.assertEqual(result_dict['_links']['view'][0]['name'], "view") self.assertEqual(result_dict['_links']['view'][0]['name'], "view")
self.assertEqual(result_dict['_links']['action_object_view'][0]['href'], self.assertEqual(result_dict['_links']['action_object_view'][0]['href'],
"%s/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % ( "%s/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_object_view'][0]['title'], "View") self.assertEqual(result_dict['_links']['action_object_view'][0]['title'], "View")
self.assertEqual(result_dict['_links']['action_object_view'][0]['name'], "view") self.assertEqual(result_dict['_links']['action_object_view'][0]['name'], "view")
self.assertEqual(result_dict['_links']['action_workflow'][0]['href'], self.assertEqual(result_dict['_links']['action_workflow'][0]['href'],
"%s/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=custom_action_no_dialog" % ( "%s/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=custom_action_no_dialog" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_workflow'][0]['title'], "Custom Action No Dialog") self.assertEqual(result_dict['_links']['action_workflow'][0]['title'], "Custom Action No Dialog")
self.assertEqual(result_dict['_links']['action_workflow'][0]['name'], "custom_action_no_dialog") self.assertEqual(result_dict['_links']['action_workflow'][0]['name'], "custom_action_no_dialog")
...@@ -373,17 +374,17 @@ class TestERP5Document_getHateoas_mode_root(ERP5HALJSONStyleSkinsMixin): ...@@ -373,17 +374,17 @@ class TestERP5Document_getHateoas_mode_root(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['action_object_new_content_action']['href'], self.assertEqual(result_dict['_links']['action_object_new_content_action']['href'],
"%s/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document" % ( "%s/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_object_new_content_action']['title'], "Create a Document") self.assertEqual(result_dict['_links']['action_object_new_content_action']['title'], "Create a Document")
self.assertEqual(result_dict['_links']['action_object_new_content_action']['name'], "create_a_document") self.assertEqual(result_dict['_links']['action_object_new_content_action']['name'], "create_a_document")
self.assertEqual(result_dict['_links']['type']['href'], 'urn:jio:get:portal_types/%s' % document.getPortalType()) self.assertEqual(result_dict['_links']['type']['href'], 'urn:jio:get:portal_types/%s' % document.getPortalType())
self.assertEqual(result_dict['_links']['type']['name'], document.getPortalType()) self.assertEqual(result_dict['_links']['type']['name'], document.getPortalType())
self.assertEqual(result_dict['title'].encode("UTF-8"), document.getTitle()) self.assertEqual(unicode2str(result_dict['title']), document.getTitle())
self.assertEqual(result_dict['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl()) self.assertEqual(result_dict['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl())
self.assertEqual(result_dict['_links']['traversed_document']['name'], document.getRelativeUrl()) self.assertEqual(result_dict['_links']['traversed_document']['name'], document.getRelativeUrl())
self.assertEqual(result_dict['_links']['traversed_document']['title'], document.getTitle().decode("UTF-8")) self.assertEqual(result_dict['_links']['traversed_document']['title'], str2unicode(document.getTitle()))
self.assertEqual(result_dict['_debug'], "root") self.assertEqual(result_dict['_debug'], "root")
@simulate('Base_getRequestUrl', '*args, **kwargs', @simulate('Base_getRequestUrl', '*args, **kwargs',
...@@ -412,21 +413,21 @@ class TestERP5Document_getHateoas_mode_root(ERP5HALJSONStyleSkinsMixin): ...@@ -412,21 +413,21 @@ class TestERP5Document_getHateoas_mode_root(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['view'][0]['href'], self.assertEqual(result_dict['_links']['view'][0]['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['view'][0]['title'], "View") self.assertEqual(result_dict['_links']['view'][0]['title'], "View")
self.assertEqual(result_dict['_links']['view'][0]['name'], "view") self.assertEqual(result_dict['_links']['view'][0]['name'], "view")
self.assertEqual(result_dict['_links']['action_object_view'][0]['href'], self.assertEqual(result_dict['_links']['action_object_view'][0]['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_object_view'][0]['title'], "View") self.assertEqual(result_dict['_links']['action_object_view'][0]['title'], "View")
self.assertEqual(result_dict['_links']['action_object_view'][0]['name'], "view") self.assertEqual(result_dict['_links']['action_object_view'][0]['name'], "view")
self.assertEqual(result_dict['_links']['action_workflow'][0]['href'], self.assertEqual(result_dict['_links']['action_workflow'][0]['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=embed_action" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=embed_action" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_workflow'][0]['title'], "Embed") self.assertEqual(result_dict['_links']['action_workflow'][0]['title'], "Embed")
self.assertEqual(result_dict['_links']['action_workflow'][0]['name'], "embed_action") self.assertEqual(result_dict['_links']['action_workflow'][0]['name'], "embed_action")
...@@ -439,7 +440,7 @@ class TestERP5Document_getHateoas_mode_root(ERP5HALJSONStyleSkinsMixin): ...@@ -439,7 +440,7 @@ class TestERP5Document_getHateoas_mode_root(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['action_object_new_content_action']['href'], self.assertEqual(result_dict['_links']['action_object_new_content_action']['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_object_new_content_action']['title'], "Create a Document") self.assertEqual(result_dict['_links']['action_object_new_content_action']['title'], "Create a Document")
self.assertEqual(result_dict['_links']['action_object_new_content_action']['name'], "create_a_document") self.assertEqual(result_dict['_links']['action_object_new_content_action']['name'], "create_a_document")
...@@ -456,10 +457,10 @@ class TestERP5Document_getHateoas_mode_root(ERP5HALJSONStyleSkinsMixin): ...@@ -456,10 +457,10 @@ class TestERP5Document_getHateoas_mode_root(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['traverse']['templated'], True) self.assertEqual(result_dict['_links']['traverse']['templated'], True)
self.assertEqual(result_dict['_links']['traverse']['name'], "Traverse") self.assertEqual(result_dict['_links']['traverse']['name'], "Traverse")
self.assertEqual(result_dict['title'].encode("UTF-8"), document.getTitle()) self.assertEqual(unicode2str(result_dict['title']), document.getTitle())
self.assertEqual(result_dict['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl()) self.assertEqual(result_dict['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl())
self.assertEqual(result_dict['_links']['traversed_document']['name'], document.getRelativeUrl()) self.assertEqual(result_dict['_links']['traversed_document']['name'], document.getRelativeUrl())
self.assertEqual(result_dict['_links']['traversed_document']['title'], document.getTitle().decode("UTF-8")) self.assertEqual(result_dict['_links']['traversed_document']['title'], str2unicode(document.getTitle()))
self.assertEqual(result_dict['default_view'], "view") self.assertEqual(result_dict['default_view'], "view")
self.assertEqual(result_dict['_debug'], "root") self.assertEqual(result_dict['_debug'], "root")
...@@ -501,21 +502,21 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -501,21 +502,21 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['view'][0]['href'], self.assertEqual(result_dict['_links']['view'][0]['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['view'][0]['title'], "View") self.assertEqual(result_dict['_links']['view'][0]['title'], "View")
self.assertEqual(result_dict['_links']['view'][0]['name'], "view") self.assertEqual(result_dict['_links']['view'][0]['name'], "view")
self.assertEqual(result_dict['_links']['action_object_view'][0]['href'], self.assertEqual(result_dict['_links']['action_object_view'][0]['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_object_view'][0]['title'], "View") self.assertEqual(result_dict['_links']['action_object_view'][0]['title'], "View")
self.assertEqual(result_dict['_links']['action_object_view'][0]['name'], "view") self.assertEqual(result_dict['_links']['action_object_view'][0]['name'], "view")
self.assertEqual(result_dict['_links']['action_workflow'][0]['href'], self.assertEqual(result_dict['_links']['action_workflow'][0]['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=custom_action_no_dialog" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=custom_action_no_dialog" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_workflow'][0]['title'], "Custom Action No Dialog") self.assertEqual(result_dict['_links']['action_workflow'][0]['title'], "Custom Action No Dialog")
self.assertEqual(result_dict['_links']['action_workflow'][0]['name'], "custom_action_no_dialog") self.assertEqual(result_dict['_links']['action_workflow'][0]['name'], "custom_action_no_dialog")
...@@ -528,17 +529,17 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -528,17 +529,17 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['action_object_new_content_action']['href'], self.assertEqual(result_dict['_links']['action_object_new_content_action']['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_object_new_content_action']['title'], "Create a Document") self.assertEqual(result_dict['_links']['action_object_new_content_action']['title'], "Create a Document")
self.assertEqual(result_dict['_links']['action_object_new_content_action']['name'], "create_a_document") self.assertEqual(result_dict['_links']['action_object_new_content_action']['name'], "create_a_document")
self.assertEqual(result_dict['_links']['type']['href'], 'urn:jio:get:portal_types/%s' % document.getPortalType()) self.assertEqual(result_dict['_links']['type']['href'], 'urn:jio:get:portal_types/%s' % document.getPortalType())
self.assertEqual(result_dict['_links']['type']['name'], document.getPortalType()) self.assertEqual(result_dict['_links']['type']['name'], document.getPortalType())
self.assertEqual(result_dict['title'].encode("UTF-8"), document.getTitle()) self.assertEqual(unicode2str(result_dict['title']), document.getTitle())
self.assertEqual(result_dict['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl()) self.assertEqual(result_dict['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl())
self.assertEqual(result_dict['_links']['traversed_document']['name'], document.getRelativeUrl()) self.assertEqual(result_dict['_links']['traversed_document']['name'], document.getRelativeUrl())
self.assertEqual(result_dict['_links']['traversed_document']['title'], document.getTitle().decode("UTF-8")) self.assertEqual(result_dict['_links']['traversed_document']['title'], str2unicode(document.getTitle()))
self.assertEqual(result_dict['_debug'], "traverse") self.assertEqual(result_dict['_debug'], "traverse")
@simulate('Base_getRequestUrl', '*args, **kwargs', @simulate('Base_getRequestUrl', '*args, **kwargs',
...@@ -594,28 +595,28 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -594,28 +595,28 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['view'][0]['href'], self.assertEqual(result_dict['_links']['view'][0]['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['view'][0]['title'], "View") self.assertEqual(result_dict['_links']['view'][0]['title'], "View")
self.assertEqual(result_dict['_links']['view'][0]['name'], "view") self.assertEqual(result_dict['_links']['view'][0]['name'], "view")
self.assertEqual(result_dict['_links']['action_object_view'][0]['href'], self.assertEqual(result_dict['_links']['action_object_view'][0]['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_object_view'][0]['title'], "View") self.assertEqual(result_dict['_links']['action_object_view'][0]['title'], "View")
self.assertEqual(result_dict['_links']['action_object_view'][0]['name'], "view") self.assertEqual(result_dict['_links']['action_object_view'][0]['name'], "view")
self.assertEqual(result_dict['_links']['action_workflow'][0]['href'], self.assertEqual(result_dict['_links']['action_workflow'][0]['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=custom_action_no_dialog&extra_param_json=eyJmb3JtX2lkIjogIkZvb192aWV3In0=" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=custom_action_no_dialog&extra_param_json=eyJmb3JtX2lkIjogIkZvb192aWV3In0=" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_workflow'][0]['title'], "Custom Action No Dialog") self.assertEqual(result_dict['_links']['action_workflow'][0]['title'], "Custom Action No Dialog")
self.assertEqual(result_dict['_links']['action_workflow'][0]['name'], "custom_action_no_dialog") self.assertEqual(result_dict['_links']['action_workflow'][0]['name'], "custom_action_no_dialog")
self.assertEqual(result_dict['_links']['action_object_jio_jump']['href'], self.assertEqual(result_dict['_links']['action_object_jio_jump']['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=jump_query" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=jump_query" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_object_jio_jump']['title'], "Queries") self.assertEqual(result_dict['_links']['action_object_jio_jump']['title'], "Queries")
self.assertEqual(result_dict['_links']['action_object_jio_jump']['name'], "jump_query") self.assertEqual(result_dict['_links']['action_object_jio_jump']['name'], "jump_query")
...@@ -628,17 +629,17 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -628,17 +629,17 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['action_object_new_content_action']['href'], self.assertEqual(result_dict['_links']['action_object_new_content_action']['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document&extra_param_json=eyJmb3JtX2lkIjogIkZvb192aWV3In0=" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document&extra_param_json=eyJmb3JtX2lkIjogIkZvb192aWV3In0=" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_object_new_content_action']['title'], "Create a Document") self.assertEqual(result_dict['_links']['action_object_new_content_action']['title'], "Create a Document")
self.assertEqual(result_dict['_links']['action_object_new_content_action']['name'], "create_a_document") self.assertEqual(result_dict['_links']['action_object_new_content_action']['name'], "create_a_document")
self.assertEqual(result_dict['_links']['type']['href'], 'urn:jio:get:portal_types/%s' % document.getPortalType()) self.assertEqual(result_dict['_links']['type']['href'], 'urn:jio:get:portal_types/%s' % document.getPortalType())
self.assertEqual(result_dict['_links']['type']['name'], document.getPortalType()) self.assertEqual(result_dict['_links']['type']['name'], document.getPortalType())
self.assertEqual(result_dict['title'].encode("UTF-8"), document.getTitle()) self.assertEqual(unicode2str(result_dict['title']), document.getTitle())
self.assertEqual(result_dict['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl()) self.assertEqual(result_dict['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl())
self.assertEqual(result_dict['_links']['traversed_document']['name'], document.getRelativeUrl()) self.assertEqual(result_dict['_links']['traversed_document']['name'], document.getRelativeUrl())
self.assertEqual(result_dict['_links']['traversed_document']['title'], document.getTitle().decode("UTF-8")) self.assertEqual(result_dict['_links']['traversed_document']['title'], str2unicode(document.getTitle()))
self.assertEqual(result_dict['_debug'], "traverse") self.assertEqual(result_dict['_debug'], "traverse")
# Check embedded form rendering # Check embedded form rendering
...@@ -682,7 +683,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -682,7 +683,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl()) self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl())
self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['name'], document.getRelativeUrl()) self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['name'], document.getRelativeUrl())
self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['title'], document.getTitle().decode("UTF-8")) self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['title'], str2unicode(document.getTitle()))
self.assertEqual(result_dict['_embedded']['_view']['_links']['self']['href'], "%s/%s/Foo_view" % ( self.assertEqual(result_dict['_embedded']['_view']['_links']['self']['href'], "%s/%s/Foo_view" % (
self.portal.absolute_url(), self.portal.absolute_url(),
...@@ -894,11 +895,11 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -894,11 +895,11 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['view'][0]['href'], self.assertEqual(result_dict['_links']['view'][0]['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['view'][0]['title'], "View") self.assertEqual(result_dict['_links']['view'][0]['title'], "View")
self.assertEqual(result_dict['_links']['view'][0]['name'], "view") self.assertEqual(result_dict['_links']['view'][0]['name'], "view")
self.assertEqual(result_dict['title'].encode("UTF-8"), document.getTitle()) self.assertEqual(unicode2str(result_dict['title']), document.getTitle())
self.assertEqual(result_dict['_debug'], "traverse") self.assertEqual(result_dict['_debug'], "traverse")
# Check embedded form rendering # Check embedded form rendering
...@@ -919,7 +920,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -919,7 +920,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl()) self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl())
self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['name'], document.getRelativeUrl()) self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['name'], document.getRelativeUrl())
self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['title'], document.getTitle().decode("UTF-8")) self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['title'], str2unicode(document.getTitle()))
self.assertEqual(result_dict['_embedded']['_view']['_links']['self']['href'], "%s/%s/Foo_view" % ( self.assertEqual(result_dict['_embedded']['_view']['_links']['self']['href'], "%s/%s/Foo_view" % (
self.portal.absolute_url(), self.portal.absolute_url(),
...@@ -967,28 +968,28 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -967,28 +968,28 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['view'][0]['href'], self.assertEqual(result_dict['_links']['view'][0]['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['view'][0]['title'], "View") self.assertEqual(result_dict['_links']['view'][0]['title'], "View")
self.assertEqual(result_dict['_links']['view'][0]['name'], "view") self.assertEqual(result_dict['_links']['view'][0]['name'], "view")
self.assertEqual(result_dict['_links']['action_object_view'][0]['href'], self.assertEqual(result_dict['_links']['action_object_view'][0]['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_object_view'][0]['title'], "View") self.assertEqual(result_dict['_links']['action_object_view'][0]['title'], "View")
self.assertEqual(result_dict['_links']['action_object_view'][0]['name'], "view") self.assertEqual(result_dict['_links']['action_object_view'][0]['name'], "view")
self.assertEqual(result_dict['_links']['action_workflow'][0]['href'], self.assertEqual(result_dict['_links']['action_workflow'][0]['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=custom_action_no_dialog&extra_param_json=eyJmb3JtX2lkIjogIkJhc2Vfdmlld01ldGFkYXRhIn0=" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=custom_action_no_dialog&extra_param_json=eyJmb3JtX2lkIjogIkJhc2Vfdmlld01ldGFkYXRhIn0=" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_workflow'][0]['title'], "Custom Action No Dialog") self.assertEqual(result_dict['_links']['action_workflow'][0]['title'], "Custom Action No Dialog")
self.assertEqual(result_dict['_links']['action_workflow'][0]['name'], "custom_action_no_dialog") self.assertEqual(result_dict['_links']['action_workflow'][0]['name'], "custom_action_no_dialog")
self.assertEqual(result_dict['_links']['action_object_jio_jump']['href'], self.assertEqual(result_dict['_links']['action_object_jio_jump']['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=jump_query" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=jump_query" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_object_jio_jump']['title'], "Queries") self.assertEqual(result_dict['_links']['action_object_jio_jump']['title'], "Queries")
self.assertEqual(result_dict['_links']['action_object_jio_jump']['name'], "jump_query") self.assertEqual(result_dict['_links']['action_object_jio_jump']['name'], "jump_query")
...@@ -1001,14 +1002,14 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -1001,14 +1002,14 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['action_object_new_content_action']['href'], self.assertEqual(result_dict['_links']['action_object_new_content_action']['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document&extra_param_json=eyJmb3JtX2lkIjogIkJhc2Vfdmlld01ldGFkYXRhIn0=" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document&extra_param_json=eyJmb3JtX2lkIjogIkJhc2Vfdmlld01ldGFkYXRhIn0=" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_object_new_content_action']['title'], "Create a Document") self.assertEqual(result_dict['_links']['action_object_new_content_action']['title'], "Create a Document")
self.assertEqual(result_dict['_links']['action_object_new_content_action']['name'], "create_a_document") self.assertEqual(result_dict['_links']['action_object_new_content_action']['name'], "create_a_document")
self.assertEqual(result_dict['_links']['type']['href'], 'urn:jio:get:portal_types/%s' % document.getPortalType()) self.assertEqual(result_dict['_links']['type']['href'], 'urn:jio:get:portal_types/%s' % document.getPortalType())
self.assertEqual(result_dict['_links']['type']['name'], document.getPortalType()) self.assertEqual(result_dict['_links']['type']['name'], document.getPortalType())
self.assertEqual(result_dict['title'].encode("UTF-8"), document.getTitle()) self.assertEqual(unicode2str(result_dict['title']), document.getTitle())
self.assertEqual(result_dict['_debug'], "traverse") self.assertEqual(result_dict['_debug'], "traverse")
# Check embedded form rendering # Check embedded form rendering
...@@ -1029,7 +1030,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -1029,7 +1030,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl()) self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl())
self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['name'], document.getRelativeUrl()) self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['name'], document.getRelativeUrl())
self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['title'], document.getTitle().decode("UTF-8")) self.assertEqual(result_dict['_embedded']['_view']['_links']['traversed_document']['title'], str2unicode(document.getTitle()))
self.assertEqual(result_dict['_embedded']['_view']['_links']['self']['href'], "%s/Base_viewMetadata" % self.assertEqual(result_dict['_embedded']['_view']['_links']['self']['href'], "%s/Base_viewMetadata" %
document.getRelativeUrl()) document.getRelativeUrl())
...@@ -1197,7 +1198,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -1197,7 +1198,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl()) self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl())
self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['_links']['traversed_document']['name'], document.getRelativeUrl()) self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['_links']['traversed_document']['name'], document.getRelativeUrl())
self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['_links']['traversed_document']['title'], document.getTitle().decode("UTF-8")) self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['_links']['traversed_document']['title'], str2unicode(document.getTitle()))
self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['_links']['form_definition']['href'], 'urn:jio:get:portal_skins/erp5_core/Base_viewWorkflowHistory') self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['_links']['form_definition']['href'], 'urn:jio:get:portal_skins/erp5_core/Base_viewWorkflowHistory')
self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['_links']['form_definition']['name'], 'Base_viewWorkflowHistory') self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['_links']['form_definition']['name'], 'Base_viewWorkflowHistory')
...@@ -1251,14 +1252,14 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -1251,14 +1252,14 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
# self.assertEqual(result_dict['_links']['view'][0]['href'], # self.assertEqual(result_dict['_links']['view'][0]['href'],
# "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=consistency" % ( # "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=consistency" % (
# self.portal.absolute_url(), # self.portal.absolute_url(),
# urllib.quote_plus("portal_skins/erp5_ui_test/Foo_view"))) # quote_plus("portal_skins/erp5_ui_test/Foo_view")))
# self.assertEqual(result_dict['_links']['view'][0]['title'], "Consistency") # self.assertEqual(result_dict['_links']['view'][0]['title'], "Consistency")
# self.assertEqual(result_dict['_links']['view'][0]['name'], "consistency") # self.assertEqual(result_dict['_links']['view'][0]['name'], "consistency")
# self.assertEqual(result_dict['_links']['action_object_view'][0]['href'], # self.assertEqual(result_dict['_links']['action_object_view'][0]['href'],
# "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=consistency" % ( # "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=consistency" % (
# self.portal.absolute_url(), # self.portal.absolute_url(),
# urllib.quote_plus("portal_skins/erp5_ui_test/Foo_view"))) # quote_plus("portal_skins/erp5_ui_test/Foo_view")))
# self.assertEqual(result_dict['_links']['action_object_view'][0]['title'], "Consistency") # self.assertEqual(result_dict['_links']['action_object_view'][0]['title'], "Consistency")
# self.assertEqual(result_dict['_links']['action_object_view'][0]['name'], "consistency") # self.assertEqual(result_dict['_links']['action_object_view'][0]['name'], "consistency")
...@@ -1299,7 +1300,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -1299,7 +1300,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
) )
result_dict = json.loads(result) result_dict = json.loads(result)
self.assertEqual(result_dict['title'].encode('UTF-8'), document.getTitle()) self.assertEqual(unicode2str(result_dict['title']), document.getTitle())
self.assertEqual( self.assertEqual(
result_dict['_embedded']['_view']['_embedded']['form_definition']['pt'], result_dict['_embedded']['_view']['_embedded']['form_definition']['pt'],
'form_view' 'form_view'
...@@ -2067,7 +2068,7 @@ return url ...@@ -2067,7 +2068,7 @@ return url
# Test the URL value # Test the URL value
self.assertEqual(result_dict['_embedded']['contents'][0]['title']['url_value']['command'], 'raw') self.assertEqual(result_dict['_embedded']['contents'][0]['title']['url_value']['command'], 'raw')
self.assertEqual(result_dict['_embedded']['contents'][0]['title']['url_value']['options'].keys(), [u'url', u'reset']) self.assertEqual(ensure_list(result_dict['_embedded']['contents'][0]['title']['url_value']['options'].keys()), [u'url', u'reset'])
self.assertEqual(result_dict['_embedded']['contents'][0]['title']['url_value']['options']['url'], 'https://officejs.com') self.assertEqual(result_dict['_embedded']['contents'][0]['title']['url_value']['options']['url'], 'https://officejs.com')
# Test if the value of the column is with right key # Test if the value of the column is with right key
...@@ -2163,7 +2164,7 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id ...@@ -2163,7 +2164,7 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id
self.assertEqual(2, len(result_dict['_embedded']['contents'])) self.assertEqual(2, len(result_dict['_embedded']['contents']))
# 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(document_list[0].getReference(), result_dict['_embedded']['contents'][0]['reference'].encode('UTF-8')) self.assertEqual(document_list[0].getReference(), unicode2str(result_dict['_embedded']['contents'][0]['reference']))
# There is a count method on the listbox # There is a count method on the listbox
self.assertEqual(result_dict['_embedded']['count'], 0) self.assertEqual(result_dict['_embedded']['count'], 0)
...@@ -2178,10 +2179,10 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id ...@@ -2178,10 +2179,10 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id
) )
result_dict = json.loads(result) result_dict = json.loads(result)
self.assertEqual(len(result_dict['_embedded']['contents']), 2) self.assertEqual(len(result_dict['_embedded']['contents']), 2)
self.assertEqual(result_dict['_embedded']['contents'][0]['title'].encode('utf-8'), document_list[0].getTitle()) self.assertEqual(unicode2str(result_dict['_embedded']['contents'][0]['title']), document_list[0].getTitle())
self.assertEqual(result_dict['_embedded']['contents'][0]['Foo_getLocalTitle'], None) self.assertEqual(result_dict['_embedded']['contents'][0]['Foo_getLocalTitle'], None)
self.assertEqual(result_dict['_embedded']['contents'][0]['getTotalQuantity'], 0) self.assertEqual(result_dict['_embedded']['contents'][0]['getTotalQuantity'], 0)
self.assertEqual(result_dict['_embedded']['contents'][1]['title'].encode('utf-8'), document_list[1].getTitle()) self.assertEqual(unicode2str(result_dict['_embedded']['contents'][1]['title']), document_list[1].getTitle())
self.assertEqual(result_dict['_embedded']['contents'][1]['Foo_getLocalTitle'], None) self.assertEqual(result_dict['_embedded']['contents'][1]['Foo_getLocalTitle'], None)
self.assertEqual(result_dict['_embedded']['contents'][1]['getTotalQuantity'], 0) self.assertEqual(result_dict['_embedded']['contents'][1]['getTotalQuantity'], 0)
# No count if not in the listbox context currently # No count if not in the listbox context currently
...@@ -2620,21 +2621,21 @@ class TestERP5Document_getHateoas_mode_bulk(ERP5HALJSONStyleSkinsMixin): ...@@ -2620,21 +2621,21 @@ class TestERP5Document_getHateoas_mode_bulk(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['result_list'][0]['_links']['view'][0]['href'], self.assertEqual(result_dict['result_list'][0]['_links']['view'][0]['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['result_list'][0]['_links']['view'][0]['title'], "View") self.assertEqual(result_dict['result_list'][0]['_links']['view'][0]['title'], "View")
self.assertEqual(result_dict['result_list'][0]['_links']['view'][0]['name'], "view") self.assertEqual(result_dict['result_list'][0]['_links']['view'][0]['name'], "view")
self.assertEqual(result_dict['result_list'][0]['_links']['action_object_view'][0]['href'], self.assertEqual(result_dict['result_list'][0]['_links']['action_object_view'][0]['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['result_list'][0]['_links']['action_object_view'][0]['title'], "View") self.assertEqual(result_dict['result_list'][0]['_links']['action_object_view'][0]['title'], "View")
self.assertEqual(result_dict['result_list'][0]['_links']['action_object_view'][0]['name'], "view") self.assertEqual(result_dict['result_list'][0]['_links']['action_object_view'][0]['name'], "view")
self.assertEqual(result_dict['result_list'][0]['_links']['action_workflow'][0]['href'], self.assertEqual(result_dict['result_list'][0]['_links']['action_workflow'][0]['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=custom_action_no_dialog&extra_param_json=eyJmb3JtX2lkIjogIkZvb192aWV3In0=" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=custom_action_no_dialog&extra_param_json=eyJmb3JtX2lkIjogIkZvb192aWV3In0=" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['result_list'][0]['_links']['action_workflow'][0]['title'], "Custom Action No Dialog") self.assertEqual(result_dict['result_list'][0]['_links']['action_workflow'][0]['title'], "Custom Action No Dialog")
self.assertEqual(result_dict['result_list'][0]['_links']['action_workflow'][0]['name'], "custom_action_no_dialog") self.assertEqual(result_dict['result_list'][0]['_links']['action_workflow'][0]['name'], "custom_action_no_dialog")
...@@ -2647,14 +2648,14 @@ class TestERP5Document_getHateoas_mode_bulk(ERP5HALJSONStyleSkinsMixin): ...@@ -2647,14 +2648,14 @@ class TestERP5Document_getHateoas_mode_bulk(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['result_list'][0]['_links']['action_object_new_content_action']['href'], self.assertEqual(result_dict['result_list'][0]['_links']['action_object_new_content_action']['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document&extra_param_json=eyJmb3JtX2lkIjogIkZvb192aWV3In0=" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document&extra_param_json=eyJmb3JtX2lkIjogIkZvb192aWV3In0=" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['result_list'][0]['_links']['action_object_new_content_action']['title'], "Create a Document") self.assertEqual(result_dict['result_list'][0]['_links']['action_object_new_content_action']['title'], "Create a Document")
self.assertEqual(result_dict['result_list'][0]['_links']['action_object_new_content_action']['name'], "create_a_document") self.assertEqual(result_dict['result_list'][0]['_links']['action_object_new_content_action']['name'], "create_a_document")
self.assertEqual(result_dict['result_list'][0]['_links']['type']['href'], 'urn:jio:get:portal_types/%s' % document.getPortalType()) self.assertEqual(result_dict['result_list'][0]['_links']['type']['href'], 'urn:jio:get:portal_types/%s' % document.getPortalType())
self.assertEqual(result_dict['result_list'][0]['_links']['type']['name'], document.getPortalType()) self.assertEqual(result_dict['result_list'][0]['_links']['type']['name'], document.getPortalType())
self.assertEqual(result_dict['result_list'][0]['title'].encode("UTF-8"), document.getTitle()) self.assertEqual(unicode2str(result_dict['result_list'][0]['title']), document.getTitle())
self.assertEqual(result_dict['result_list'][0]['_debug'], "traverse") self.assertEqual(result_dict['result_list'][0]['_debug'], "traverse")
# Check embedded form rendering # Check embedded form rendering
...@@ -2675,7 +2676,7 @@ class TestERP5Document_getHateoas_mode_bulk(ERP5HALJSONStyleSkinsMixin): ...@@ -2675,7 +2676,7 @@ class TestERP5Document_getHateoas_mode_bulk(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['result_list'][0]['_embedded']['_view']['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl()) self.assertEqual(result_dict['result_list'][0]['_embedded']['_view']['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl())
self.assertEqual(result_dict['result_list'][0]['_embedded']['_view']['_links']['traversed_document']['name'], document.getRelativeUrl()) self.assertEqual(result_dict['result_list'][0]['_embedded']['_view']['_links']['traversed_document']['name'], document.getRelativeUrl())
self.assertEqual(result_dict['result_list'][0]['_embedded']['_view']['_links']['traversed_document']['title'], document.getTitle().decode("UTF-8")) self.assertEqual(result_dict['result_list'][0]['_embedded']['_view']['_links']['traversed_document']['title'], str2unicode(document.getTitle()))
self.assertEqual(result_dict['result_list'][0]['_embedded']['_view']['_links']['self']['href'], "%s/%s/Foo_view" % ( self.assertEqual(result_dict['result_list'][0]['_embedded']['_view']['_links']['self']['href'], "%s/%s/Foo_view" % (
self.portal.absolute_url(), self.portal.absolute_url(),
...@@ -2737,8 +2738,10 @@ class TestERP5Document_getHateoas_mode_worklist(ERP5HALJSONStyleSkinsMixin): ...@@ -2737,8 +2738,10 @@ class TestERP5Document_getHateoas_mode_worklist(ERP5HALJSONStyleSkinsMixin):
self.assertTrue(work_list[0]['count'] > 0) self.assertTrue(work_list[0]['count'] > 0)
self.assertEqual(work_list[0]['name'], 'Draft To Validate') self.assertEqual(work_list[0]['name'], 'Draft To Validate')
self.assertNotIn('module', work_list[0]) self.assertNotIn('module', work_list[0])
self.assertEqual(work_list[0]['href'], 'urn:jio:allDocs?query=portal_type%3A%28%22Bar%22%20OR%20%22Foo%22%29%20AND%20simulation_state%3A%22draft%22') self.assertIn(work_list[0]['href'], (
'urn:jio:allDocs?query=portal_type%3A%28%22Bar%22%20OR%20%22Foo%22%29%20AND%20simulation_state%3A%22draft%22',
'urn:jio:allDocs?query=simulation_state%3A%22draft%22%20AND%20portal_type%3A%28%22Bar%22%20OR%20%22Foo%22%29',
))
self.assertEqual(result_dict['_debug'], "worklist") self.assertEqual(result_dict['_debug'], "worklist")
...@@ -2846,7 +2849,7 @@ if translation_service is not None :\n\ ...@@ -2846,7 +2849,7 @@ if translation_service is not None :\n\
if not encoding:\n\ if not encoding:\n\
return translation_service.translate(catalog, msg, lang=lang, **kw)\n\ return translation_service.translate(catalog, msg, lang=lang, **kw)\n\
msg = translation_service.translate(catalog, msg, lang=lang, **kw)\n\ msg = translation_service.translate(catalog, msg, lang=lang, **kw)\n\
if same_type(msg, u''):\n\ if str==bytes and same_type(msg, u''):\n\
msg = msg.encode(encoding)\n\ msg = msg.encode(encoding)\n\
return msg\n\ return msg\n\
except AttributeError:\n\ except AttributeError:\n\
...@@ -2910,7 +2913,7 @@ return msg" ...@@ -2910,7 +2913,7 @@ return msg"
self.assertEqual(result_dict['_links']['type']['href'], 'urn:jio:get:portal_types/%s' % document.getPortalType()) self.assertEqual(result_dict['_links']['type']['href'], 'urn:jio:get:portal_types/%s' % document.getPortalType())
self.assertEqual(result_dict['_links']['type']['name'], 'Foo_zhongwen') self.assertEqual(result_dict['_links']['type']['name'], 'Foo_zhongwen')
self.assertEqual(result_dict['title'].encode("UTF-8"), document.getTitle()) self.assertEqual(unicode2str(result_dict['title']), document.getTitle())
self.assertEqual(result_dict['_debug'], "root") self.assertEqual(result_dict['_debug'], "root")
@simulate('Base_getRequestUrl', '*args, **kwargs', @simulate('Base_getRequestUrl', '*args, **kwargs',
...@@ -2938,7 +2941,10 @@ return msg" ...@@ -2938,7 +2941,10 @@ return msg"
self.assertEqual(work_list[0]['name'], 'daiyanzhen') self.assertEqual(work_list[0]['name'], 'daiyanzhen')
self.assertEqual(work_list[0]['count'], 1) self.assertEqual(work_list[0]['count'], 1)
self.assertNotIn('module', work_list[0]) self.assertNotIn('module', work_list[0])
self.assertEqual(work_list[0]['href'], 'urn:jio:allDocs?query=portal_type%3A%28%22Bar%22%20OR%20%22Foo%22%29%20AND%20simulation_state%3A%22draft%22') self.assertIn(work_list[0]['href'], (
'urn:jio:allDocs?query=portal_type%3A%28%22Bar%22%20OR%20%22Foo%22%29%20AND%20simulation_state%3A%22draft%22',
'urn:jio:allDocs?query=simulation_state%3A%22draft%22%20AND%20portal_type%3A%28%22Bar%22%20OR%20%22Foo%22%29',
))
self.assertEqual(result_dict['_debug'], "worklist") self.assertEqual(result_dict['_debug'], "worklist")
...@@ -3007,7 +3013,7 @@ return msg" ...@@ -3007,7 +3013,7 @@ return msg"
result_dict = json.loads(result) result_dict = json.loads(result)
# The document title includes 'ö' at the last in this test class, so calling decode("UTF-8") # The document title includes 'ö' at the last in this test class, so calling decode("UTF-8")
self.assertEqual(result_dict['_links']['parent'], self.assertEqual(result_dict['_links']['parent'],
{"href": "urn:jio:get:%s" % document.getRelativeUrl(), "name": document.getTitle().decode("UTF-8")}) {"href": "urn:jio:get:%s" % document.getRelativeUrl(), "name": str2unicode(document.getTitle())})
# make sure traversing the child document does not adding the parent title translation # make sure traversing the child document does not adding the parent title translation
self.assertFalse(message_catalog.message_exists(document_title)) self.assertFalse(message_catalog.message_exists(document_title))
......
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