[Erp5-report] r27859 - in /erp5/trunk/products: ERP5/tests/ ERP5Type/tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Jul 2 10:36:22 CEST 2009


Author: seb
Date: Thu Jul  2 10:36:19 2009
New Revision: 27859

URL: http://svn.erp5.org?rev=27859&view=rev
Log:
* merge two _addPropertySheet methods to a single method
* change the way parameters are passed to _addPropertySheet when
  the unified method is different from the original one

Modified:
    erp5/trunk/products/ERP5/tests/testCalendar.py
    erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py
    erp5/trunk/products/ERP5Type/tests/testConstraint.py
    erp5/trunk/products/ERP5Type/tests/testERP5Type.py

Modified: erp5/trunk/products/ERP5/tests/testCalendar.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testCalendar.py?rev=27859&r1=27858&r2=27859&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testCalendar.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testCalendar.py [utf8] Thu Jul  2 10:36:19 2009
@@ -112,13 +112,6 @@
     transaction.commit()
     self.tic()
 
-  def _addPropertySheet(self, type_info_name, property_sheet_name):
-    ti = self.portal.portal_types.getTypeInfo(type_info_name)
-    if property_sheet_name not in ti.property_sheet_list:
-      ti.property_sheet_list = tuple(ti.property_sheet_list)\
-                                      + (property_sheet_name,)
-      _aq_reset()
-
   def stepCreatePerson(self, sequence=None, sequence_list=None, **kw):
     """
     Create an person

Modified: erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py?rev=27859&r1=27858&r2=27859&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py [utf8] Thu Jul  2 10:36:19 2009
@@ -46,6 +46,7 @@
                                     removeLocalConstraint, \
                                     importLocalConstraint
 from Products.DCWorkflow.DCWorkflow import ValidationFailed
+from Products.ERP5Type.Base import _aq_reset
 from zLOG import LOG, DEBUG
 
 # Quiet messages when installing products
@@ -517,6 +518,39 @@
       return getattr(self.getPortal(), 'currency_module',
           getattr(self.getPortal(), 'currency', None))
 
+    def _addPropertySheet(self, portal_type_name,
+                         property_sheet_name='TestPropertySheet',
+                         property_sheet_code=None):
+      """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)
+        transaction.commit()
+        class_tool.importPropertySheet(property_sheet_name)
+      
+      # We set the property sheet on the portal type
+      ti = self.getTypesTool().getTypeInfo(portal_type_name)
+      if property_sheet_name not in ti.property_sheet_list:
+        ti.property_sheet_list = list(ti.property_sheet_list) +\
+                                    [property_sheet_name]
+
+      # remember that we added a property sheet for tear down
+      if getattr(self, '_added_property_sheets', None) is not None:
+        self._added_property_sheets.setdefault(
+                    portal_type_name, []).append(property_sheet_name)
+      # reset aq_dynamic cache
+      _aq_reset()
+
     def validateRules(self):
       """
       try to validate all rules in rule_tool.

Modified: erp5/trunk/products/ERP5Type/tests/testConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testConstraint.py?rev=27859&r1=27858&r2=27859&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/testConstraint.py [utf8] Thu Jul  2 10:36:19 2009
@@ -1270,7 +1270,8 @@
     self.assertEquals([], constraint.checkConsistency(obj))
     # now add a 'local_property' property defined on a property sheet
     self._addPropertySheet(obj.getPortalType(),
-      '''class TestPropertySheet: _categories=('testing_category',)''')
+      property_sheet_code=\
+       '''class TestPropertySheet: _categories=('testing_category',)''')
     # fix consistency
     constraint.fixConsistency(obj)
     # now we can use testing_category as any category accessor
@@ -1397,6 +1398,7 @@
     obj = self._makeOne()
     obj.setTitle('b')
     self._addPropertySheet(obj.getPortalType(),
+      property_sheet_code=\
       '''class TestPropertySheet:
           _constraints = (
             { 'id': 'testing_constraint',
@@ -1417,6 +1419,7 @@
     obj = self._makeOne()
     obj.setTitle('b')
     self._addPropertySheet(obj.getPortalType(),
+      property_sheet_code=\
       '''class TestPropertySheet:
           _constraints = (
             { 'id': 'testing_constraint',

Modified: erp5/trunk/products/ERP5Type/tests/testERP5Type.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testERP5Type.py?rev=27859&r1=27858&r2=27859&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testERP5Type.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/testERP5Type.py [utf8] Thu Jul  2 10:36:19 2009
@@ -95,37 +95,8 @@
   _properties = ( %(property_definition_code)s, )
 """ % locals()
     self._addPropertySheet(portal_type_name,
-                           property_sheet_code,
-                           property_sheet_name)
-
-  def _addPropertySheet(self, portal_type_name, property_sheet_code,
-                       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()
-
-    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)
-    transaction.commit()
-    class_tool.importPropertySheet(property_sheet_name)
-    
-    # We set the property sheet on the portal type
-    ti = self.getTypesTool().getTypeInfo(portal_type_name)
-    ti.property_sheet_list = list(ti.property_sheet_list) +\
-                                [property_sheet_name]
-    # 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
-    _aq_reset()
-
+                           property_sheet_code=property_sheet_code,
+                           property_sheet_name=property_sheet_name)
 
 class TestERP5Type(PropertySheetTestCase, LogInterceptor):
     """Tests ERP5TypeInformation and per portal type generated accessors.
@@ -622,7 +593,7 @@
       )
 
 """
-      self._addPropertySheet('Organisation', text)
+      self._addPropertySheet('Organisation', property_sheet_code=text)
       folder = self.getOrganisationModule()
       # We check that we raise exception when we create new object
       from Products.ERP5Type.Utils import ConstraintNotFound
@@ -2047,7 +2018,7 @@
       )
 
 """
-      self._addPropertySheet('Person', text)
+      self._addPropertySheet('Person', property_sheet_code=text)
 
       # Create a new person, and associate it to beta and gamma.
       module = self.getPersonModule()




More information about the Erp5-report mailing list