Commit 70340ec3 authored by Nicolas Dumazet's avatar Nicolas Dumazet

add a (failing) test to check listbox behavior when listbox field and a

listbox_xx field have inconsistent "editable" property:
Check that the listbox takes over.

(It was the case before r33620)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33631 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 550378ea
No related merge requests found
......@@ -28,6 +28,7 @@
import unittest
from lxml import etree
import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
......@@ -377,6 +378,58 @@ return []
self._helperExtraAndCssInListboxLine("LinesField", True)
self._helperExtraAndCssInListboxLine("LinesField", False)
def test_09_editablePropertyPrecedence(self):
"""
When listbox's editable column and listbox_xx's editable property
conflict, the listbox editable column choice should take over.
For example, if listbox_foo is defined as editable, without
having column "foo" listed as editable in the listbox, the field should
not be rendered as editable
"""
portal = self.getPortal()
portal.ListBoxZuite_reset()
field_name = 'noneditable'
field_id = 'listbox_noneditable'
# Reset listbox properties
listbox = portal.FooModule_viewFooList.listbox
listbox.ListBox_setPropertyList(
field_list_method = 'portal_catalog',
field_columns = ['%s | Check extra' % field_name,],
)
form = portal.FooModule_viewFooList
form.manage_addField(field_id, field_name, "StringField")
field = getattr(form, field_id)
field.values['default'] = '42'
field.values['editable'] = True
form.groups['bottom'].remove(field_id)
form.groups['hidden'].append(field_id)
# Create an new empty object with a list property
foo_module = portal.foo_module
o = foo_module.newContent()
# Reindex
o.immediateReindexObject()
# Render the module in html
request = get_request()
request['here'] = portal.foo_module
rendered_listbox = listbox.render(REQUEST=request)
html = etree.HTML(rendered_listbox)
# When a StringField is editable, it is rendered as an input
# with name: "field_%(field_id)s_%(object_id)s"
editable_field_list = html.xpath(
'//input[starts-with(@name, $name)]',
name='field_%s_' % field_id,
)
self.assertEquals(len(editable_field_list), 0)
def test_ObjectSupport(self):
# make sure listbox supports rendering of simple objects
# the only requirement is that objects have a `uid` attribute which is a
......
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