Commit 280783b1 authored by Łukasz Nowak's avatar Łukasz Nowak

- provide utility class which can be used to check if subcontent of some...

 - 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


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37289 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1e7c3f9f
......@@ -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_type, cell_range_method, cell_dict_list):
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()
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