[Erp5-report] r40584 arnaud.fontaine - /erp5/trunk/products/ERP5Type/tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Nov 24 10:31:19 CET 2010


Author: arnaud.fontaine
Date: Wed Nov 24 10:31:17 2010
New Revision: 40584

URL: http://svn.erp5.org?rev=40584&view=rev
Log:
Remove meaningless returns and avoid duplication of the code testing
the constraints

Modified:
    erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py

Modified: erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py?rev=40584&r1=40583&r2=40584&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py [utf8] Wed Nov 24 10:31:17 2010
@@ -252,7 +252,7 @@ class TestZodbPropertySheet(ERP5TypeTest
     """
     Create a new Standard Property within test Property Sheet
     """
-    return self.test_property_sheet.newContent(
+    self.test_property_sheet.newContent(
       portal_type='Standard Property',
       reference='test_standard_property_' + operation_type,
       property_default='python: "test_default_value"',
@@ -262,7 +262,7 @@ class TestZodbPropertySheet(ERP5TypeTest
     """
     Create a new Acquired Property within test Property Sheet
     """
-    return self.test_property_sheet.newContent(
+    self.test_property_sheet.newContent(
       portal_type='Acquired Property',
       reference='test_acquired_property_' + operation_type,
       elementary_type='content',
@@ -300,7 +300,7 @@ class TestZodbPropertySheet(ERP5TypeTest
 
     self._newCategoryTree(category_id, operation_type)
 
-    return self.test_property_sheet.newContent(
+    self.test_property_sheet.newContent(
       reference=category_id,
       portal_type='Category Property')
 
@@ -314,7 +314,7 @@ class TestZodbPropertySheet(ERP5TypeTest
 
     expression = "python: ('%s',)" % category_id
 
-    return self.test_property_sheet.newContent(
+    self.test_property_sheet.newContent(
       portal_type='Dynamic Category Property',
       category_expression=expression,
       reference=category_id)
@@ -324,7 +324,7 @@ class TestZodbPropertySheet(ERP5TypeTest
     Create a new Property Existence Constraint within test Property
     Sheet
     """
-    return self.test_property_sheet.newContent(
+    self.test_property_sheet.newContent(
       reference='test_property_existence_constraint',
       portal_type='Property Existence Constraint',
       constraint_property_list=('test_standard_property_constraint',))
@@ -336,7 +336,7 @@ class TestZodbPropertySheet(ERP5TypeTest
     """
     self._newCategoryProperty('constraint')
 
-    return self.test_property_sheet.newContent(
+    self.test_property_sheet.newContent(
       reference='test_category_existence_constraint',
       portal_type='Category Existence Constraint',
       constraint_base_category_list=('test_category_property_constraint',))
@@ -725,40 +725,42 @@ class TestZodbPropertySheet(ERP5TypeTest
 
     return None
 
-  def testPropertyExistenceConstraint(self):
+  def _checkConstraint(self,
+                       constraint_reference,
+                       setter_function,
+                       value):
     """
-    Take the test module and check whether the Property Existence
-    Constraint is available. Until the property has been set to a
-    value, the constraint should fail
+    Check whether the given constraint has been properly defined and
+    checkConsistency() is correct
     """
-    constraint = self._getConstraintByReference(
-      'test_property_existence_constraint')
-
+    constraint = self._getConstraintByReference(constraint_reference)
     self.failIfEqual(None, constraint)
-
     self.assertEquals(1, len(constraint.checkConsistency(self.test_module)))
 
-    # See ERP5Type.Base.Base.hasProperty()
-    self.test_module.setTestStandardPropertyConstraint('foobar')
-
+    setter_function(value)
     self.assertEquals([], constraint.checkConsistency(self.test_module))
 
+  def testPropertyExistenceConstraint(self):
+    """
+    Take the test module and check whether the Property Existence
+    Constraint is available. Until the property has been set to a
+    value, the constraint should fail
+
+    @see ERP5Type.Base.Base.hasProperty
+    """
+    self._checkConstraint('test_property_existence_constraint',
+                          self.test_module.setTestStandardPropertyConstraint,
+                          'foobar')
+
   def testCategoryExistenceConstraint(self):
     """
     Take the test module and check whether the Property Existence
     Constraint is available. Until the category has been set to an
     existing category, the constraint should fail
     """
-    constraint = self._getConstraintByReference(
-      'test_category_existence_constraint')
-
-    self.failIfEqual(None, constraint)
-
-    self.assertEquals(1, len(constraint.checkConsistency(self.test_module)))
-
-    self.test_module.setTestCategoryPropertyConstraint('sub_category')
-
-    self.assertEquals([], constraint.checkConsistency(self.test_module))
+    self._checkConstraint('test_category_existence_constraint',
+                          self.test_module.setTestCategoryPropertyConstraint,
+                          'sub_category')
 
 TestZodbPropertySheet = skip("ZODB Property Sheets code is not enabled yet")(
   TestZodbPropertySheet)




More information about the Erp5-report mailing list