[Erp5-report] r29236 - in /erp5/trunk/products: ERP5Catalog/tests/ ZSQLCatalog/SearchText/

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Sep 28 17:35:47 CEST 2009


Author: seb
Date: Mon Sep 28 17:35:47 2009
New Revision: 29236

URL: http://svn.erp5.org?rev=29236&view=rev
Log:
* add unit test to make sure that parenthesis in strings
  are not a problem for catalog research

* As suggested by Vincent, do not make parenthesis a criterion
  to swith to advanced search. This solve issue when you
  have documents with such titles :
    foo (bar)
  Before, the catalog was looking at title=foo AND title=bar

Modified:
    erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py
    erp5/trunk/products/ZSQLCatalog/SearchText/AdvancedSearchTextDetector.py

Modified: erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py?rev=29236&r1=29235&r2=29236&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py [utf8] (original)
+++ erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py [utf8] Mon Sep 28 17:35:47 2009
@@ -3850,6 +3850,26 @@
     person1.is_indexable = person2.is_indexable = True
     self.assertRaises(ValueError, portal_catalog.catalogObjectList,[person1, person2])
 
+  def test_SearchFolderWithParenthesis(self, quiet=quiet):
+    if not quiet:
+      message = 'Search Folder With Parenthesis'
+      ZopeTestCase._print('\n%s ' % message)
+      LOG('Testing... ',0,message)
+
+    person_module = self.getPersonModule()
+
+    # Make sure that the catalog will not split it with such research :
+    # title=foo AND title=bar
+    title='foo (bar)'
+    person = person_module.newContent(portal_type='Person',title=title)
+    person_id = person.getId()
+    person.immediateReindexObject()
+    folder_object_list = [x.getObject().getId() for x in person_module.searchFolder()]
+    self.assertTrue(person_id in folder_object_list)
+    folder_object_list = [x.getObject().getId() for x in 
+                              person_module.searchFolder(title=title)]
+    self.assertEquals([person_id],folder_object_list)
+  
 def test_suite():
   suite = unittest.TestSuite()
   suite.addTest(unittest.makeSuite(TestERP5Catalog))

Modified: erp5/trunk/products/ZSQLCatalog/SearchText/AdvancedSearchTextDetector.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SearchText/AdvancedSearchTextDetector.py?rev=29236&r1=29235&r2=29236&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SearchText/AdvancedSearchTextDetector.py [utf8] (original)
+++ erp5/trunk/products/ZSQLCatalog/SearchText/AdvancedSearchTextDetector.py [utf8] Mon Sep 28 17:35:47 2009
@@ -37,7 +37,10 @@
     return t
 
   def t_LEFT_PARENTHESE(self, t):
-    self.found = True
+    t.type = 'WORD'
+    return t
+
+  def t_RIGHT_PARENTHESE(self, t):
     t.type = 'WORD'
     return t
 




More information about the Erp5-report mailing list