Commit 91c4afdc authored by Jérome Perrin's avatar Jérome Perrin

tests that ignore_empty_string works as expected with related keys


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17681 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 28fcdc03
......@@ -2031,6 +2031,40 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
ctool(portal_type='Organisation', title=dict(query='Foo%',
key='ExactMatch'))])
def test_ignore_empty_string(self):
# ERP5Catalog ignore empty strings by default
doc_with_title = self._makeOrganisation(title='X')
doc_with_empty_title = self._makeOrganisation(title='')
ctool = self.getCatalogTool()
def searchResults(**kw):
kw['portal_type'] = 'Organisation'
return set([x.getObject() for x in ctool.searchResults(**kw)])
# title='' is ignored
self.assertEquals(set([doc_with_empty_title, doc_with_title]),
searchResults(title=''))
# unless we exlicitly say we don't want to ignore empty strings
self.assertEquals(set([doc_with_empty_title]),
searchResults(ignore_empty_string=0, title=''))
def test_ignore_empty_string_related_key(self):
# ERP5Catalog ignore empty strings by default, also on related keys
region_with_empty_title = self.portal.portal_categories.region.newContent(
portal_type='Category', title='')
doc_with_empty_region_title = self._makeOrganisation(title='X',
region_value=region_with_empty_title)
doc_without_region = self._makeOrganisation(title='')
ctool = self.getCatalogTool()
def searchResults(**kw):
kw['portal_type'] = 'Organisation'
return set([x.getObject() for x in ctool.searchResults(**kw)])
self.assertEquals(set([doc_with_empty_region_title, doc_without_region]),
searchResults(region_title=''))
self.assertEquals(set([doc_with_empty_region_title]),
searchResults(ignore_empty_string=0, region_title=''))
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5Catalog))
......
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