Commit 01eade7b authored by Sebastien Robin's avatar Sebastien Robin

added test to check if we can sort a string field like a int field


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3905 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 01a11cd7
......@@ -318,13 +318,37 @@ class TestERP5Catalog(ERP5TypeTestCase):
person.immediateReindexObject()
person = person_module.newContent(id='c',portal_type='Person',title='a',description='x')
person.immediateReindexObject()
folder_object_list = [x.getObject().getId() for x in person_module.searchFolder(sort_on=[('id','ascendign')])]
folder_object_list = [x.getObject().getId() for x in person_module.searchFolder(sort_on=[('id','ascending')])]
self.assertEquals(['a','b','c'],folder_object_list)
folder_object_list = [x.getObject().getId() for x in person_module.searchFolder(sort_on=[('title','ascendign'),('description','ascending')])]
folder_object_list = [x.getObject().getId() for x in person_module.searchFolder(sort_on=[('title','ascending'),('description','ascending')])]
self.assertEquals(['c','b','a'],folder_object_list)
folder_object_list = [x.getObject().getId() for x in person_module.searchFolder(sort_on=[('title','ascendign'),('description','descending')])]
folder_object_list = [x.getObject().getId() for x in person_module.searchFolder(sort_on=[('title','ascending'),('description','descending')])]
self.assertEquals(['a','b','c'],folder_object_list)
def test_11_CastStringAsInt(self, quiet=0, run=run_all_test):
if not run: return
if not quiet:
message = 'Cast String As Int With Order By'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
person_module = self.getPersonModule()
# Clear catalog
portal_catalog = self.getCatalogTool()
portal_catalog.manage_catalogClear()
person = person_module.newContent(id='a',portal_type='Person',title='1')
person.immediateReindexObject()
person = person_module.newContent(id='b',portal_type='Person',title='2')
person.immediateReindexObject()
person = person_module.newContent(id='c',portal_type='Person',title='12')
person.immediateReindexObject()
folder_object_list = [x.getObject().getTitle() for x in person_module.searchFolder(sort_on=[('title','ascending')])]
self.assertEquals(['1','12','2'],folder_object_list)
folder_object_list = [x.getObject().getTitle() for x in person_module.searchFolder(sort_on=[('title','ascending','int')])]
self.assertEquals(['1','2','12'],folder_object_list)
def atest_99_BadCatalog(self, quiet=0, run=run_all_test):
"""
We should make sure that if a catalog method fails,
......
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