Commit 8a08fe3b authored by Carlos Ramos Carreño's avatar Carlos Ramos Carreño

Fix erp5_officejs tests in Python 2

See merge request !1920
parents a29c3532 a94bda6b
...@@ -8,6 +8,8 @@ Redirect to domain specified as layout property on website ...@@ -8,6 +8,8 @@ Redirect to domain specified as layout property on website
import binascii import binascii
import base64 import base64
from Products.ERP5Type.Utils import bytes2str, str2bytes
import six
result_dict = {"error":"url missing definition view path"} result_dict = {"error":"url missing definition view path"}
base_64 = False base_64 = False
...@@ -19,8 +21,9 @@ except KeyError: ...@@ -19,8 +21,9 @@ except KeyError:
return result_dict return result_dict
try: try:
encoded = name.replace("definition_view/", "", 1).encode() encoded = str2bytes(name.replace("definition_view/", "", 1))
name = base64.decodebytes(encoded).decode() decode_method = base64.decodebytes if six.PY3 else base64.decodestring
name = bytes2str(decode_method(encoded))
base_64 = True base_64 = True
except binascii.Error: except binascii.Error:
pass pass
......
import json import json
import base64 import base64
from erp5.component.module.Log import log from erp5.component.module.Log import log
from Products.ERP5Type.Utils import bytes2str, str2bytes
def getElementFromContent(key, content): def getElementFromContent(key, content):
before_template = '"%s" type="text/x-renderjs-configuration">' before_template = '"%s" type="text/x-renderjs-configuration">'
...@@ -69,22 +70,22 @@ try: ...@@ -69,22 +70,22 @@ try:
configuration_path_list = [] configuration_path_list = []
for key in portal_actions_dict: for key in portal_actions_dict:
path = "portal_types/%s" % key path = "portal_types/%s" % key
configuration_path_list.append(base64.b64encode(path.encode()).decode()) configuration_path_list.append(bytes2str(base64.b64encode(str2bytes(path))))
for action in portal_actions_dict[key]: for action in portal_actions_dict[key]:
path = "portal_types/%s/%s" % (key, action) path = "portal_types/%s/%s" % (key, action)
configuration_path_list.append(base64.b64encode(path.encode()).decode()) configuration_path_list.append(bytes2str(base64.b64encode(str2bytes(path))))
try: try:
action_object = context.restrictedTraverse(path) action_object = context.restrictedTraverse(path)
form = action_object.getActionText().split('/')[-1] form = action_object.getActionText().split('/')[-1]
path = "portal_skins/%s/%s" % (portal_skin, form) path = "portal_skins/%s/%s" % (portal_skin, form)
configuration_path_list.append(base64.b64encode(path.encode()).decode()) configuration_path_list.append(bytes2str(base64.b64encode(str2bytes(path))))
except KeyError as e: except KeyError as e:
raise KeyError("Error getting portal action info: " + str(e)) raise KeyError("Error getting portal action info: " + str(e))
if new_dialog_form_list: if new_dialog_form_list:
for form in new_dialog_form_list: for form in new_dialog_form_list:
path = "portal_skins/%s/%s" % (portal_skin, form) path = "portal_skins/%s/%s" % (portal_skin, form)
configuration_path_list.append(base64.b64encode(path.encode()).decode()) configuration_path_list.append(bytes2str(base64.b64encode(str2bytes(path))))
url_list = [] url_list = []
for path in configuration_path_list: for path in configuration_path_list:
......
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
from Products.ERP5Type.Utils import bytes2str
portal = context.getPortalObject() portal = context.getPortalObject()
support_request = context.getFollowUpValue() support_request = context.getFollowUpValue()
web_site_value = portal.restrictedTraverse(web_site_relative_url) web_site_value = portal.restrictedTraverse(web_site_relative_url)
...@@ -34,7 +35,7 @@ web_message = portal.event_module.newContent( ...@@ -34,7 +35,7 @@ web_message = portal.event_module.newContent(
portal_type='Web Message', portal_type='Web Message',
title=context.getTitle() if context.hasTitle() else None, title=context.getTitle() if context.hasTitle() else None,
content_type='text/html' if is_html else 'text/plain', content_type='text/html' if is_html else 'text/plain',
text_content=data.decode('utf-8'), text_content=bytes2str(data),
follow_up_value=support_request, follow_up_value=support_request,
aggregate_value_list=[context] + context.getSuccessorValueList( aggregate_value_list=[context] + context.getSuccessorValueList(
portal_type=portal.getPortalDocumentTypeList()), portal_type=portal.getPortalDocumentTypeList()),
......
...@@ -42,7 +42,7 @@ from ZPublisher.HTTPResponse import HTTPResponse ...@@ -42,7 +42,7 @@ from ZPublisher.HTTPResponse import HTTPResponse
from zExceptions.ExceptionFormatter import format_exception from zExceptions.ExceptionFormatter import format_exception
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.runUnitTest import log_directory from Products.ERP5Type.tests.runUnitTest import log_directory
from Products.ERP5Type.Utils import stopProcess, PR_SET_PDEATHSIG from Products.ERP5Type.Utils import stopProcess, PR_SET_PDEATHSIG, unicode2str
from lxml import etree from lxml import etree
from lxml.html.builder import E from lxml.html.builder import E
import certifi import certifi
...@@ -398,7 +398,7 @@ class FunctionalTestRunner: ...@@ -398,7 +398,7 @@ class FunctionalTestRunner:
for test_tr in test_table.xpath('.//tr[contains(@class, "status_failed")]'): for test_tr in test_table.xpath('.//tr[contains(@class, "status_failed")]'):
test_tr.set('style', 'background-color: red;') test_tr.set('style', 'background-color: red;')
details_attribute_dict = {} details_attribute_dict = {}
if "expected failure" in etree.tostring(test_table, encoding="unicode"): if u"expected failure" in etree.tostring(test_table, encoding="unicode"):
expected_failure_amount += 1 expected_failure_amount += 1
else: else:
failure_amount += 1 failure_amount += 1
...@@ -406,7 +406,7 @@ class FunctionalTestRunner: ...@@ -406,7 +406,7 @@ class FunctionalTestRunner:
details_attribute_dict['open'] = 'true' details_attribute_dict['open'] = 'true'
detail_element = E.div() detail_element = E.div()
detail_element.append(E.details(E.summary(test_name), test_table, **details_attribute_dict)) detail_element.append(E.details(E.summary(test_name), test_table, **details_attribute_dict))
detail += etree.tostring(detail_element, encoding="unicode") detail += unicode2str(etree.tostring(detail_element, encoding="unicode"))
tr_count += 1 tr_count += 1
success_amount = tr_count - 1 - failure_amount - expected_failure_amount success_amount = tr_count - 1 - failure_amount - expected_failure_amount
if detail: if detail:
......
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