Commit 89b67f94 authored by Nicolas Dumazet's avatar Nicolas Dumazet

arg, several tests were using those utility methods.

Clarify the situation: raise useful errors.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42865 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e4b2e9d4
...@@ -399,12 +399,16 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase): ...@@ -399,12 +399,16 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
getattr(self.getPortal(), 'currency', None)) getattr(self.getPortal(), 'currency', None))
def _addPropertySheet(self, portal_type_name, def _addPropertySheet(self, portal_type_name,
property_sheet_name='TestPropertySheet'): property_sheet_name='TestPropertySheet',
deprecated=None):
"""Utility method to add a property sheet to a type information. """Utility method to add a property sheet to a type information.
You might be interested in the higer level method _addProperty You might be interested in the higer level method _addProperty
This method registers all added property sheets, to be able to remove This method registers all added property sheets, to be able to remove
them in tearDown. them in tearDown.
""" """
if deprecated is not None:
raise ValueError("Please update this test to use ZODB property sheets")
portal_property_sheets = self.portal.portal_property_sheets portal_property_sheets = self.portal.portal_property_sheets
property_sheet = getattr(portal_property_sheets, property_sheet_name, None) property_sheet = getattr(portal_property_sheets, property_sheet_name, None)
if property_sheet is None: if property_sheet is None:
......
...@@ -83,13 +83,26 @@ class PropertySheetTestCase(ERP5TypeTestCase): ...@@ -83,13 +83,26 @@ class PropertySheetTestCase(ERP5TypeTestCase):
transaction.commit() transaction.commit()
super(PropertySheetTestCase, self).tearDown() super(PropertySheetTestCase, self).tearDown()
def _addProperty(self, portal_type_name, property_sheet_id, property_id, def _addProperty(self, portal_type_name, property_sheet_id,
property_id=None,
commit=True, **kw): commit=True, **kw):
"""quickly add a property to a type""" """quickly add a property to a type
self.assertTrue('portal_type' in kw)
It always associate / create the property sheet with id
property_sheet_id to the portal type portal_type_name.
When property_sheet_id is passed, we create a property of this
id, using kw** as parameters to the constructor.
"""
ps = self._addPropertySheet(portal_type_name, ps = self._addPropertySheet(portal_type_name,
property_sheet_name=property_sheet_id) property_sheet_name=property_sheet_id)
if property_id is not None:
if "\n" in property_id:
raise ValueError("Please update this test to use ZODB property sheets")
self.assertTrue('portal_type' in kw)
property = getattr(ps, property_id, None) property = getattr(ps, property_id, None)
if property is not None: if property is not None:
ps._delObject(property_id) ps._delObject(property_id)
......
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