From 913f2dd757bf92251ce6c6db130eafc26e2d51bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com> Date: Tue, 27 Jul 2010 14:37:17 +0000 Subject: [PATCH] - factoring: use SubcontentReindexingWrapper git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37291 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/tests/testOrder.py | 50 ++------------------------------- 1 file changed, 3 insertions(+), 47 deletions(-) diff --git a/product/ERP5/tests/testOrder.py b/product/ERP5/tests/testOrder.py index a638b5e4f8..d41f74c736 100644 --- a/product/ERP5/tests/testOrder.py +++ b/product/ERP5/tests/testOrder.py @@ -33,25 +33,15 @@ import os import transaction 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 DateTime import DateTime from zLOG import LOG from Products.ERP5Type.tests.Sequence import SequenceList 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, - 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: +class TestOrderMixin(SubcontentReindexingWrapper): default_quantity = 99 default_price = 555 @@ -80,40 +70,6 @@ class TestOrderMixin: user = uf.getUserById('rc').__of__(uf) 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): #create apparel variation preferences portal_preferences = self.getPreferenceTool() -- 2.30.9