Commit acd28780 authored by Julien Muchembled's avatar Julien Muchembled

Simplify _testSubContentReindexing

parent 69dcc9db
...@@ -635,50 +635,27 @@ def updateCellList(portal, line, cell_type, cell_range_method, cell_dict_list): ...@@ -635,50 +635,27 @@ def updateCellList(portal, line, cell_type, cell_range_method, cell_dict_list):
cell.edit(predicate_category_list=category_list, cell.edit(predicate_category_list=category_list,
variation_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): 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): def _testSubContentReindexing(self, parent_document, children_document_list):
"""Helper method which shall be called *before* tic or commit"""
# cleanup existing reindexing
transaction.commit() transaction.commit()
self.tic() self.tic()
parent_document.reindexObject() def catalogObjectList(self, object_list, *args, **kw):
self.portal.catalogged_object_path_dict = PersistentMapping() """Wrapper to track list of catalogged objects"""
transaction.commit() for q in object_list:
expected_path_list = [q.getPath() for q in children_document_list + catalogged_object_path_set.add(q.getPath())
[parent_document]] return orig_catalogObjectList(self, object_list, *args, **kw)
orig_catalogObjectList = Catalog.__dict__['catalogObjectList']
expected_path_set = set(q.getPath()
for q in children_document_list + [parent_document])
self.assertEqual(expected_path_set, set(x.getPath()
for x in self.portal.portal_catalog(path=expected_path_set)))
try: try:
# wrap call to catalogObjectList Catalog.catalogObjectList = catalogObjectList
self.wrap_catalogObjectList() catalogged_object_path_set = set()
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() parent_document.reindexObject()
self.stepTic() transaction.commit()
self.assertSameSet( self.tic()
self.portal.catalogged_object_path_dict.keys(), self.assertEqual(expected_path_set, catalogged_object_path_set)
expected_path_list
)
finally: finally:
# unwrap catalogObjectList Catalog.catalogObjectList = orig_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