From 59d79c3b7cfb9b4e449878366d0e822415baadd5 Mon Sep 17 00:00:00 2001 From: Ivan Tyagov <ivan@nexedi.com> Date: Tue, 31 Aug 2010 11:56:12 +0000 Subject: [PATCH] Test selection of listbox columns based on list_style. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38068 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Form/tests/testListBox.py | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/product/ERP5Form/tests/testListBox.py b/product/ERP5Form/tests/testListBox.py index ff53d637e6..f44a26384a 100644 --- a/product/ERP5Form/tests/testListBox.py +++ b/product/ERP5Form/tests/testListBox.py @@ -43,6 +43,7 @@ from StringIO import StringIO from Products.ERP5Form.Selection import Selection from Products.ERP5Form.Form import ERP5Form from Products.Formulator.TALESField import TALESMethod +from Products.ERP5Form.ListBox import ListBoxHTMLRenderer class DummyFieldStorage: @@ -558,6 +559,46 @@ return [] self.assertEquals([('proxy_value', 'Proxy')], title_line.getColumnItemList()) + def test_ListStyleColumnsSelections(self): + """ + Test list style columns selections. + """ + def getListBoxRenderer(listbox): + return ListBoxHTMLRenderer(self, listbox, request) + + portal = self.getPortal() + portal.ListBoxZuite_reset() + listbox = portal.FooModule_viewFooList.listbox + listbox.ListBox_setPropertyList( + field_style_columns=['title | thumbnail_Title', + 'thumbnail | thumbnail_Thumbnail', + 'getIconAsHTML | search_Icon', + 'getSummaryAsHTML | search_Summary', + 'B | rss_title', + 'C | rss_description'],) + request = get_request() + + # explicitly setting (dynamically) renderer columns list + renderer = getListBoxRenderer(listbox) + renderer.setDisplayedColumnIdList(['title', 'id']) + self.assertSameSet([('title', u'Title'), ('id', u'ID')], + renderer.getSelectedColumnList()) + + # default(no list_style) + self.assertEqual(getListBoxRenderer(listbox).getDefaultDisplayStyle(), getListBoxRenderer(listbox).getListboxDisplayStyle()) + self.assertSameSet([('id', u'ID'), ('title', u'Title'), ('getQuantity', u'Quantity')], + getListBoxRenderer(listbox).getSelectedColumnList()) + + request.set('list_style', 'search') + self.assertEqual('search', getListBoxRenderer(listbox).getListboxDisplayStyle()) + self.assertSameSet([('getIconAsHTML', 'Icon'), ('getSummaryAsHTML', 'Summary')], + getListBoxRenderer(listbox).getSelectedColumnList()) + + request.set('list_style', 'thumbnail') + self.assertEqual('thumbnail', getListBoxRenderer(listbox).getListboxDisplayStyle()) + self.assertSameSet([('title', 'Title'), ('thumbnail', 'Thumbnail')], + getListBoxRenderer(listbox).getSelectedColumnList()) + def test_suite(): suite = unittest.TestSuite() -- 2.30.9