Commit 79065efa authored by Julien Muchembled's avatar Julien Muchembled

There is no need to create temporary classes for Constraint and PropertySheet

Also make related unit test more strict.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32812 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c1d0a4aa
......@@ -5578,10 +5578,8 @@ Business Template is a set of definitions, such as skins, portal types and categ
# This is required if the BT contains instances of one of these classes.
orig_module_dict = {}
instance_oid_list = []
for template_type in ('Constraint', 'Document', 'PropertySheet'):
for template_id in getattr(self,
'getTemplate%sIdList' % template_type)():
module_id = 'Products.ERP5Type.%s.%s' % (template_type, template_id)
for template_id in self.getTemplateDocumentIdList():
module_id = 'Products.ERP5Type.Document.' + template_id
orig_module_dict[module_id] = sys.modules.get(module_id)
# Always redefine the module, so that 'instance_oid_list' contains
# the full list of oid to remove from pickle cache.
......
......@@ -5946,11 +5946,10 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
def test_167_InstanceAndRelatedClassDefinedInSameBT(self):
from Products.ERP5Type.Document.BusinessTemplate import BaseTemplateItem
BaseTemplateItem_removeProperties = BaseTemplateItem.removeProperties
object_id_list = []
marker_list = []
def removeProperties(self, obj):
# Check it works if the object is modified during download.
object_id_list.append(obj.id)
obj.title = 'foo'
obj.int_index = marker_list.pop()
return obj
SimpleItem_getCopy = SimpleItem._getCopy
try:
......@@ -5960,15 +5959,16 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
bt_path = os.path.join(os.path.dirname(__file__), 'test_data',
self._testMethodName)
for i in xrange(6):
marker_list.append(i)
gc.disable()
bt = template_tool.download(bt_path)
assert object_id_list.pop() == 'some_file' and not object_id_list
assert not marker_list
if i in (2, 4, 5):
transaction.commit()
self.tic()
bt.install(force=1)
gc.enable()
assert not object_id_list
self.assertEqual(self.portal.some_file.int_index, i)
transaction.commit()
self.tic()
finally:
......
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