[Erp5-report] r37289 luke - /erp5/trunk/products/ERP5Type/tests/utils.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Jul 27 16:29:24 CEST 2010
Author: luke
Date: Tue Jul 27 16:29:16 2010
New Revision: 37289
URL: http://svn.erp5.org?rev=37289&view=rev
Log:
- provide utility class which can be used to check if subcontent of some object are reindexed upon parent reindexation, by checking list of to-be-indexed paths
Modified:
erp5/trunk/products/ERP5Type/tests/utils.py
Modified: erp5/trunk/products/ERP5Type/tests/utils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/utils.py?rev=37289&r1=37288&r2=37289&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/utils.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/utils.py [utf8] Tue Jul 27 16:29:16 2010
@@ -40,6 +40,8 @@ import Products.ERP5Type
from Products.MailHost.MailHost import MailHost
from email import message_from_string
import backportUnittest
+from Products.ERP5Type.Globals import PersistentMapping
+from Products.ZSQLCatalog.SQLCatalog import Catalog
class FileUpload(file):
"""Act as an uploaded file.
@@ -542,3 +544,51 @@ def updateCellList(portal, line, cell_ty
cell.setMembershipCriterionCategoryList(membership_criterion_category_list)
cell.edit(predicate_category_list=category_list,
variation_category_list=category_list)
+
+def catalogObjectListWrapper(self, object_list, method_id_list=None,
+ disable_cache=0, check_uid=1, idxs=None):
+ """Wrapper to mark inside of portal object list of catalogged objects"""
+ import transaction
+ portal = self.getPortalObject()
+ for q in object_list:
+ portal.catalogged_object_path_dict[q.getPath()] = 1
+ transaction.commit()
+
+class SubcontentReindexingWrapper(object):
+ def wrap_catalogObjectList(self):
+ self.original_catalogObjectList = Catalog.catalogObjectList
+ Catalog.catalogObjectList = catalogObjectListWrapper
+
+ def unwrap_catalogObjectList(self):
+ Catalog.catalogObjectList = self.original_catalogObjectList
+
+ def _testSubContentReindexing(self, parent_document, children_document_list):
+ """Helper method which shall be called *before* tic or commit"""
+ # cleanup existing reindexing
+ transaction.commit()
+ self.tic()
+ parent_document.reindexObject()
+ self.portal.catalogged_object_path_dict = PersistentMapping()
+ transaction.commit()
+ expected_path_list = [q.getPath() for q in children_document_list +
+ [parent_document]]
+ try:
+ # wrap call to catalogObjectList
+ self.wrap_catalogObjectList()
+ self.stepTic()
+ self.assertSameSet(
+ self.portal.catalogged_object_path_dict.keys(),
+ expected_path_list
+ )
+ # do real assertions
+ self.portal.catalogged_object_path_dict = PersistentMapping()
+ transaction.commit()
+ parent_document.reindexObject()
+ self.stepTic()
+ self.assertSameSet(
+ self.portal.catalogged_object_path_dict.keys(),
+ expected_path_list
+ )
+ finally:
+ # unwrap catalogObjectList
+ self.unwrap_catalogObjectList()
More information about the Erp5-report
mailing list