Commit ffd66c63 authored by Yusei Tahara's avatar Yusei Tahara

Use Base.checkConsistency to test constraints instead. This is the method...

Use Base.checkConsistency to test constraints instead. This is the method which real users are using.
parent b346c6b5
...@@ -456,7 +456,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -456,7 +456,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
self.test_property_sheet.newContent( self.test_property_sheet.newContent(
reference='test_content_existence_constraint', reference='test_content_existence_constraint',
portal_type='Content Existence Constraint', portal_type='Content Existence Constraint',
constraint_portal_type='python: ("Content Existence Constraint")') constraint_portal_type='python: ("Test Document")')
def _newCategoryMembershipArityConstraint(self, def _newCategoryMembershipArityConstraint(self,
reference, reference,
...@@ -588,6 +588,16 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -588,6 +588,16 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
type_property_sheet_list=('TestMigration',), type_property_sheet_list=('TestMigration',),
type_base_category_list=('test_category_existence_constraint',), type_base_category_list=('test_category_existence_constraint',),
type_filter_content_type=False) type_filter_content_type=False)
# Create a Portal Type for subobject of Test Migration
try:
self.test_subobject_portal_type = getattr(portal.portal_types, 'Test Document')
except AttributeError:
self.test_subobject_portal_type = portal.portal_types.newContent(
id='Test Document',
portal_type='Base Type',
type_class='Folder',
type_filter_content_type=False)
self.test_portal_type.setTypeAllowedContentTypeList(['Test Document'])
# Create a test module, meaningful to force generation of # Create a test module, meaningful to force generation of
# TestMigration accessor holders and check the constraints # TestMigration accessor holders and check the constraints
...@@ -926,10 +936,15 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -926,10 +936,15 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
**kw): **kw):
constraint = self._getConstraintByReference(constraint_reference) constraint = self._getConstraintByReference(constraint_reference)
self.failIfEqual(None, constraint) self.failIfEqual(None, constraint)
self.assertEquals(1, len(constraint.checkConsistency(self.test_module)))
# Use Base.checkConsistency!!
# This is the standard interface which real users are always using.
# Never call ConstraintMixin.checkConsistency directly in unit test.
# You will miss serious bugs.
self.assertEquals(1, len(self.test_module.checkConsistency(filter={'reference':constraint_reference})))
setter_function(*args, **kw) setter_function(*args, **kw)
self.assertEquals([], constraint.checkConsistency(self.test_module)) self.assertEquals([], self.test_module.checkConsistency(filter={'reference':constraint_reference}))
def testPropertyExistenceConstraint(self): def testPropertyExistenceConstraint(self):
""" """
...@@ -985,15 +1000,14 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -985,15 +1000,14 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
def testContentExistenceConstraint(self): def testContentExistenceConstraint(self):
""" """
Take the test module and check whether the Content Existence Take the test module and check whether the Test Document is there.
Constraint is there. Until there is at least one subobject of Until there is at least one subobject of 'Test Module' whose Portal
'Test Module' whose Portal Type is 'Folder', the constraint should Type is 'Folder', the constraint should fail
fail
""" """
self._checkConstraint('test_content_existence_constraint', self._checkConstraint('test_content_existence_constraint',
self.test_module.newContent, self.test_module.newContent,
id='Test Content Existence Constraint', id='Test Content Existence Constraint',
portal_type='Content Existence Constraint') portal_type='Test Document')
def testCategoryMembershipArityConstraint(self): def testCategoryMembershipArityConstraint(self):
""" """
......
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