Commit 3e40fdb4 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Remove meaningless returns and avoid duplication of the code testing

the constraints


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40584 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 45c3fb61
...@@ -252,7 +252,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -252,7 +252,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
""" """
Create a new Standard Property within test Property Sheet Create a new Standard Property within test Property Sheet
""" """
return self.test_property_sheet.newContent( self.test_property_sheet.newContent(
portal_type='Standard Property', portal_type='Standard Property',
reference='test_standard_property_' + operation_type, reference='test_standard_property_' + operation_type,
property_default='python: "test_default_value"', property_default='python: "test_default_value"',
...@@ -262,7 +262,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -262,7 +262,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
""" """
Create a new Acquired Property within test Property Sheet Create a new Acquired Property within test Property Sheet
""" """
return self.test_property_sheet.newContent( self.test_property_sheet.newContent(
portal_type='Acquired Property', portal_type='Acquired Property',
reference='test_acquired_property_' + operation_type, reference='test_acquired_property_' + operation_type,
elementary_type='content', elementary_type='content',
...@@ -300,7 +300,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -300,7 +300,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
self._newCategoryTree(category_id, operation_type) self._newCategoryTree(category_id, operation_type)
return self.test_property_sheet.newContent( self.test_property_sheet.newContent(
reference=category_id, reference=category_id,
portal_type='Category Property') portal_type='Category Property')
...@@ -314,7 +314,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -314,7 +314,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
expression = "python: ('%s',)" % category_id expression = "python: ('%s',)" % category_id
return self.test_property_sheet.newContent( self.test_property_sheet.newContent(
portal_type='Dynamic Category Property', portal_type='Dynamic Category Property',
category_expression=expression, category_expression=expression,
reference=category_id) reference=category_id)
...@@ -324,7 +324,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -324,7 +324,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
Create a new Property Existence Constraint within test Property Create a new Property Existence Constraint within test Property
Sheet Sheet
""" """
return self.test_property_sheet.newContent( self.test_property_sheet.newContent(
reference='test_property_existence_constraint', reference='test_property_existence_constraint',
portal_type='Property Existence Constraint', portal_type='Property Existence Constraint',
constraint_property_list=('test_standard_property_constraint',)) constraint_property_list=('test_standard_property_constraint',))
...@@ -336,7 +336,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -336,7 +336,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
""" """
self._newCategoryProperty('constraint') self._newCategoryProperty('constraint')
return self.test_property_sheet.newContent( self.test_property_sheet.newContent(
reference='test_category_existence_constraint', reference='test_category_existence_constraint',
portal_type='Category Existence Constraint', portal_type='Category Existence Constraint',
constraint_base_category_list=('test_category_property_constraint',)) constraint_base_category_list=('test_category_property_constraint',))
...@@ -725,40 +725,42 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -725,40 +725,42 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
return None return None
def testPropertyExistenceConstraint(self): def _checkConstraint(self,
constraint_reference,
setter_function,
value):
""" """
Take the test module and check whether the Property Existence Check whether the given constraint has been properly defined and
Constraint is available. Until the property has been set to a checkConsistency() is correct
value, the constraint should fail
""" """
constraint = self._getConstraintByReference( constraint = self._getConstraintByReference(constraint_reference)
'test_property_existence_constraint')
self.failIfEqual(None, constraint) self.failIfEqual(None, constraint)
self.assertEquals(1, len(constraint.checkConsistency(self.test_module))) self.assertEquals(1, len(constraint.checkConsistency(self.test_module)))
# See ERP5Type.Base.Base.hasProperty() setter_function(value)
self.test_module.setTestStandardPropertyConstraint('foobar')
self.assertEquals([], constraint.checkConsistency(self.test_module)) 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): def testCategoryExistenceConstraint(self):
""" """
Take the test module and check whether the Property Existence Take the test module and check whether the Property Existence
Constraint is available. Until the category has been set to an Constraint is available. Until the category has been set to an
existing category, the constraint should fail existing category, the constraint should fail
""" """
constraint = self._getConstraintByReference( self._checkConstraint('test_category_existence_constraint',
'test_category_existence_constraint') self.test_module.setTestCategoryPropertyConstraint,
'sub_category')
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))
TestZodbPropertySheet = skip("ZODB Property Sheets code is not enabled yet")( TestZodbPropertySheet = skip("ZODB Property Sheets code is not enabled yet")(
TestZodbPropertySheet) TestZodbPropertySheet)
......
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