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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Georgios Dagkakis
erp5
Commits
af34ccfc
Commit
af34ccfc
authored
Mar 23, 2016
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Form: test various cases of encoding in listbox properties / URL columns
parent
f537d4e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
0 deletions
+99
-0
product/ERP5Form/tests/testListBox.py
product/ERP5Form/tests/testListBox.py
+99
-0
No files found.
product/ERP5Form/tests/testListBox.py
View file @
af34ccfc
...
...
@@ -242,6 +242,105 @@ class TestListBox(ERP5TypeTestCase):
listbox
.
get_value
(
'default'
,
render_format
=
'list'
,
REQUEST
=
request
)
except
UnicodeError
,
e
:
self
.
fail
(
'Rendering failed: %s'
%
e
)
self
.
assertIn
(
u"
\
xe9
lisa"
,
listbox
.
render
(
REQUEST
=
request
))
def
test_UTF8Parameters
(
self
,
quiet
=
0
,
run
=
run_all_test
):
"""UTF8 encoded string properties are also handled
"""
portal
=
self
.
getPortal
()
portal
.
ListBoxZuite_reset
()
# We create a script to use as a list method
list_method_id
=
'ListBox_ParametersListMethod'
createZODBPythonScript
(
portal
.
portal_skins
.
custom
,
list_method_id
,
'selection=None, **kw'
,
"""return [context.asContext(alternate_title = u'
\
xe9
lisa'.encode('utf8'))]"""
)
# set the listbox to use this as list method
listbox
=
portal
.
FooModule_viewFooList
.
listbox
listbox
.
ListBox_setPropertyList
(
field_list_method
=
list_method_id
,
field_count_method
=
''
,
field_columns
=
[
'alternate_title | Alternate Title'
,],
field_url_columns
=
[
'alternate_title | alternate_title'
,],)
request
=
get_request
()
request
[
'here'
]
=
portal
.
foo_module
try
:
listbox
.
get_value
(
'default'
,
render_format
=
'list'
,
REQUEST
=
request
)
except
UnicodeError
,
e
:
self
.
fail
(
'Rendering failed: %s'
%
e
)
self
.
assertIn
(
u"
\
xe9
lisa"
,
listbox
.
render
(
REQUEST
=
request
))
def
test_UnicodeURLColumns
(
self
,
quiet
=
0
,
run
=
run_all_test
):
"""URL column script can return unicode
"""
portal
=
self
.
getPortal
()
portal
.
ListBoxZuite_reset
()
# We create a script to use as a url column method
url_column_method_id
=
'Base_get%sUrlColumnMethod'
%
self
.
id
()
createZODBPythonScript
(
portal
.
portal_skins
.
custom
,
url_column_method_id
,
'selection=None, **kw'
,
"""return u'http://example.com/?
\
xe9
lisa'"""
)
listbox
=
portal
.
FooModule_viewFooList
.
listbox
# here we cover two cases, id has an editable field, title has not
listbox
.
ListBox_setPropertyList
(
field_url_columns
=
[
'title | %s'
%
url_column_method_id
,
'id | %s'
%
url_column_method_id
,
],)
foo_module
=
portal
.
foo_module
o
=
foo_module
.
newContent
(
title
=
u'
\
xe9
lisa'
)
o
.
immediateReindexObject
()
request
=
get_request
()
request
[
'here'
]
=
portal
.
foo_module
try
:
rendered
=
listbox
.
get_value
(
'default'
,
render_format
=
'list'
,
REQUEST
=
request
)
except
UnicodeError
,
e
:
self
.
fail
(
'Rendering failed: %s'
%
e
)
self
.
assertIn
(
u"http://example.com/?
\
xe9
lisa"
,
listbox
.
render
(
REQUEST
=
request
))
def
test_UTF8URLColumns
(
self
,
quiet
=
0
,
run
=
run_all_test
):
"""URL column script can return UTF8 encoded string
"""
portal
=
self
.
getPortal
()
portal
.
ListBoxZuite_reset
()
# We create a script to use as a url column method
url_column_method_id
=
'Base_get%sUrlColumnMethod'
%
self
.
id
()
createZODBPythonScript
(
portal
.
portal_skins
.
custom
,
url_column_method_id
,
'selection=None, **kw'
,
"""return u'http://example.com/?
\
xe9
lisa'.encode('utf8')"""
)
listbox
=
portal
.
FooModule_viewFooList
.
listbox
# here we cover two cases, id has an editable field, title has not
listbox
.
ListBox_setPropertyList
(
field_url_columns
=
[
'title | %s'
%
url_column_method_id
,
'id | %s'
%
url_column_method_id
,
],)
foo_module
=
portal
.
foo_module
o
=
foo_module
.
newContent
(
title
=
u'
\
xe9
lisa'
)
o
.
immediateReindexObject
()
request
=
get_request
()
request
[
'here'
]
=
portal
.
foo_module
try
:
rendered
=
listbox
.
get_value
(
'default'
,
render_format
=
'list'
,
REQUEST
=
request
)
except
UnicodeError
,
e
:
self
.
fail
(
'Rendering failed: %s'
%
e
)
self
.
assertIn
(
u"http://example.com/?
\
xe9
lisa"
,
listbox
.
render
(
REQUEST
=
request
))
def
test_05_EditSelectionWithFileUpload
(
self
,
quiet
=
quiet
,
run
=
run_all_test
):
"""Listbox edits selection with request parameters. Special care must be
...
...
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