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
Labels
Merge Requests
141
Merge Requests
141
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
892fe12a
Commit
892fe12a
authored
Feb 18, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HalJsonStyle: py3 (OK py2)
parent
e7e94f6d
Changes
1
Show 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 @
892fe12a
...
...
@@ -16,6 +16,7 @@ from six.moves import cStringIO as StringIO
import
json
import
re
from
six.moves.urllib.parse
import
quote
,
quote_plus
import
six
import
mock
from
zope.globalrequest
import
setRequest
# pylint: disable=no-name-in-module, import-error
...
...
@@ -1324,7 +1325,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
def test_getHateoasDocument_property_corrupted_encoding(self):
document = self._makeDocument()
# 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")
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)
...
...
@@ -1332,9 +1333,10 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
"application/hal+json"
)
result_dict = json.loads(result)
self.assertEqual(result_dict['
_embedded
']['
_view
']['
my_title
']['
default
'], u'
\
ufffd
\
ufffd
\
ufffd
')
self.assertEqual(result_dict['
title
'], u'
\
ufffd
\
ufffd
\
ufffd
')
self.assertEqual(result_dict['
_embedded
']['
_view
']['
_links
']['
traversed_document
']['
title
'], u'
\
ufffd
\
ufffd
\
ufffd
')
expected = u'
\
ufffd
\
ufffd
\
ufffd
' if six.PY2 else u'
\
udce9
\
udccf
\
udcf3
\
udcaf
'
self.assertEqual(result_dict['
_embedded
']['
_view
']['
my_title
']['
default
'], expected)
self.assertEqual(result_dict['
title
'], expected)
self.assertEqual(result_dict['
_embedded
']['
_view
']['
_links
']['
traversed_document
']['
title
'], expected)
class TestERP5Document_getHateoas_mode_search(ERP5HALJSONStyleSkinsMixin):
...
...
@@ -1682,10 +1684,12 @@ class TestERP5Document_getHateoas_mode_search(ERP5HALJSONStyleSkinsMixin):
def test_getHateoas_default_param_json_param(self):
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(
TypeError,
# "Unknown columns.*'
\\
xc3
\\
xaa
'.",
"Unknown columns.*
\
\
\
\
xc3
\
\
\
\
xaa.*",
unknown_columns_re,
self.portal.web_site_module.hateoas.ERP5Document_getHateoas,
REQUEST=fake_request,
mode="search",
...
...
@@ -1725,7 +1729,7 @@ return context.getPortalObject().foo_module.contentValues()
form_relative_url='
portal_skins
/
erp5_ui_test
/
FooModule_viewFooList
/
listbox
'
)
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
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
')
...
...
@@ -2422,7 +2426,7 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id
@
changeSkin
(
'Hal'
)
def
test_getHateoas_property_corrupted_encoding
(
self
,
document
):
# 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()
fake_request
=
do_fake_request
(
"GET"
)
...
...
@@ -2439,7 +2443,9 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id
result_dict
=
json
.
loads
(
result
)
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
):
...
...
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