Commit 3f15db48 authored by Nicolas Dumazet's avatar Nicolas Dumazet

convert testERP5Type to ZODB property sheets

Main guidelines:
* no more property sheet creation through ClassTool,
  use Property Sheet Tool instead
* ban _aq_reset and use resetDynamicDocuments instead
* everytime an action on a portal type/workflow is done,
  we have to wait for the transaction boundary, as those
  workflows delay the resetDynamicDocuments at the end
  of the transaction. hence the many new commits()

This test is too big and poorly isolated.
I expect this commit to add as much as 4 errors and 4 failures
when run sequentially; but when each of those errors/failures
are run individually, they do not fail.
This issue needs more investigation, but is not related to the
migration, hence the early commit.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42825 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5eb2b567
......@@ -400,37 +400,31 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
getattr(self.getPortal(), 'currency', None))
def _addPropertySheet(self, portal_type_name,
property_sheet_name='TestPropertySheet',
property_sheet_code=None):
property_sheet_name='TestPropertySheet'):
"""Utility method to add a property sheet to a type information.
You might be interested in the higer level method _addProperty
This method registers all added property sheets, to be able to remove
them in tearDown.
"""
# install the 'real' class tool
class_tool = self.getClassTool()
if property_sheet_code is not None:
class_tool.newPropertySheet(property_sheet_name)
# XXX need to commit the transaction at this point, because class tool
# files are no longer available to the current transaction.
transaction.commit()
class_tool.editPropertySheet(property_sheet_name, property_sheet_code)
portal_property_sheets = self.portal.portal_property_sheets
property_sheet = getattr(portal_property_sheets, property_sheet_name, None)
if property_sheet is None:
property_sheet = portal_property_sheets.newContent(id=property_sheet_name)
transaction.commit()
class_tool.importPropertySheet(property_sheet_name)
# We set the property sheet on the portal type
types_tool = self.getTypesTool()
ti = types_tool.getTypeInfo(portal_type_name)
property_sheet_set = set(ti.getTypePropertySheetList())
property_sheet_set.add(property_sheet_name)
ti._setTypePropertySheetList(list(property_sheet_set))
ti.setTypePropertySheetList(list(property_sheet_set))
transaction.commit()
# remember that we added a property sheet for tear down
self._added_property_sheets.setdefault(
portal_type_name, []).append(property_sheet_name)
# reset aq_dynamic cache
types_tool.resetDynamicDocuments()
return property_sheet
def getRule(self, **kw):
return self.portal.portal_rules.searchFolder(
......
This diff is collapsed.
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