Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
erp5
Commits
492612e4
Commit
492612e4
authored
Feb 18, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HalJsonStyle: py3 (OK py2)
parent
4fb957c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
...plateItem/portal_components/test.erp5.testHalJsonStyle.py
+15
-9
No files found.
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
View file @
492612e4
...
@@ -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)
...
@@ -1332,9 +1333,10 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
...
@@ -1332,9 +1333,10 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
"application/hal+json"
"application/hal+json"
)
)
result_dict = json.loads(result)
result_dict = json.loads(result)
self.assertEqual(result_dict['
_embedded
']['
_view
']['
my_title
']['
default
'], u'
\
ufffd
\
ufffd
\
ufffd
')
expected = u'
\
ufffd
\
ufffd
\
ufffd
' if six.PY2 else u'
\
udce9
\
udccf
\
udcf3
\
udcaf
'
self.assertEqual(result_dict['
title
'], u'
\
ufffd
\
ufffd
\
ufffd
')
self.assertEqual(result_dict['
_embedded
']['
_view
']['
my_title
']['
default
'], expected)
self.assertEqual(result_dict['
_embedded
']['
_view
']['
_links
']['
traversed_document
']['
title
'], u'
\
ufffd
\
ufffd
\
ufffd
')
self.assertEqual(result_dict['
title
'], expected)
self.assertEqual(result_dict['
_embedded
']['
_view
']['
_links
']['
traversed_document
']['
title
'], expected)
class TestERP5Document_getHateoas_mode_search(ERP5HALJSONStyleSkinsMixin):
class TestERP5Document_getHateoas_mode_search(ERP5HALJSONStyleSkinsMixin):
...
@@ -1682,10 +1684,12 @@ class TestERP5Document_getHateoas_mode_search(ERP5HALJSONStyleSkinsMixin):
...
@@ -1682,10 +1684,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 +1729,7 @@ return context.getPortalObject().foo_module.contentValues()
...
@@ -1725,7 +1729,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)
#
edital
ble creation date is defined at proxy form
#
edita
ble 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 +2426,7 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id
...
@@ -2422,7 +2426,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"
)
...
@@ -2439,7 +2443,9 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id
...
@@ -2439,7 +2443,9 @@ 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'
]),
1
)
self
.
assertEqual
(
len
(
result_dict
[
'_embedded'
][
'contents'
]),
1
)
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
"title"
],
u'
\
ufffd
\
ufffd
\
ufffd
'
)
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
"title"
],
u'
\
ufffd
\
ufffd
\
ufffd
'
if
six
.
PY2
else
u'
\
udce9
\
udccf
\
udcf3
\
udcaf
'
)
class
TestERP5Person_getHateoas_mode_search
(
ERP5HALJSONStyleSkinsMixin
):
class
TestERP5Person_getHateoas_mode_search
(
ERP5HALJSONStyleSkinsMixin
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment