Commit 913f2dd7 authored by Łukasz Nowak's avatar Łukasz Nowak

- factoring: use SubcontentReindexingWrapper


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37291 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 11a775d3
...@@ -33,25 +33,15 @@ import os ...@@ -33,25 +33,15 @@ import os
import transaction import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import FileUpload from Products.ERP5Type.tests.utils import FileUpload,\
SubcontentReindexingWrapper
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from DateTime import DateTime from DateTime import DateTime
from zLOG import LOG from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.Globals import PersistentMapping
from Products.ZSQLCatalog.SQLCatalog import Catalog
def catalogObjectListWrapper(self, object_list, method_id_list=None, class TestOrderMixin(SubcontentReindexingWrapper):
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 TestOrderMixin:
default_quantity = 99 default_quantity = 99
default_price = 555 default_price = 555
...@@ -80,40 +70,6 @@ class TestOrderMixin: ...@@ -80,40 +70,6 @@ class TestOrderMixin:
user = uf.getUserById('rc').__of__(uf) user = uf.getUserById('rc').__of__(uf)
newSecurityManager(None, user) newSecurityManager(None, user)
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"""
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()
def setUpPreferences(self): def setUpPreferences(self):
#create apparel variation preferences #create apparel variation preferences
portal_preferences = self.getPreferenceTool() portal_preferences = self.getPreferenceTool()
......
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