Commit 1a4f7cf1 authored by Arnaud Fontaine's avatar Arnaud Fontaine

'Standard Property' must be in 'property' Portal Type Group since 687fedda (#20161014-1C29326).

Otherwise, reset is not triggered when changing a 'Standard Property'
ZODB Property Sheet (through dynamic_class_generation_interaction_workflow
ChangeProperty_resetDynamicClasses Interaction). Also, add Unit Tests to
check that this Interaction is properly called.

'Base Category' was also removed in 687fedda but this does not seem to be
an issue as 'Category Property' and 'Dynamic Category Property' only use
the ID, and thus this is handled by PropertySheet_resetDynamicClasses
Interaction (_delObject/_setObject will be called).
parent ecf4af3a
...@@ -45,6 +45,14 @@ ...@@ -45,6 +45,14 @@
<key> <string>factory</string> </key> <key> <string>factory</string> </key>
<value> <string>addStandardProperty</string> </value> <value> <string>addStandardProperty</string> </value>
</item> </item>
<item>
<key> <string>group_list</string> </key>
<value>
<tuple>
<string>property</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Standard Property</string> </value> <value> <string>Standard Property</string> </value>
......
...@@ -372,7 +372,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -372,7 +372,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
new_base_category.newContent(reference='sub_category2', new_base_category.newContent(reference='sub_category2',
portal_type='Category') portal_type='Category')
if operation_type == 'change': if operation_type == 'change_reference':
self.portal.portal_categories.newContent( self.portal.portal_categories.newContent(
id=base_category_id + '_renamed', id=base_category_id + '_renamed',
portal_type='Base Category') portal_type='Base Category')
...@@ -564,7 +564,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -564,7 +564,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
self._newPropertyTypeValidityConstraint() self._newPropertyTypeValidityConstraint()
# Create all the test Properties # Create all the test Properties
for operation_type in ('change', 'delete', 'assign'): for operation_type in ('change_reference', 'change', 'delete', 'assign'):
self._newStandardProperty(operation_type) self._newStandardProperty(operation_type)
self._newAcquiredProperty(operation_type) self._newAcquiredProperty(operation_type)
self._newCategoryProperty(operation_type) self._newCategoryProperty(operation_type)
...@@ -791,7 +791,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -791,7 +791,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
self._newDynamicCategoryProperty, self._newDynamicCategoryProperty,
'getTestDynamicCategoryPropertyAdd') 'getTestDynamicCategoryPropertyAdd')
def _checkChangePropertyOfZodbPropertySheet(self, def _checkChangePropertyReferenceOfZodbPropertySheet(self,
change_setter_func, change_setter_func,
new_value, new_value,
changed_accessor_name): changed_accessor_name):
...@@ -809,47 +809,100 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -809,47 +809,100 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
self.assertHasAttribute(erp5.accessor_holder.property_sheet.TestMigration, self.assertHasAttribute(erp5.accessor_holder.property_sheet.TestMigration,
changed_accessor_name) changed_accessor_name)
def testChangeStandardPropertyOfZodbPropertySheet(self): def testChangeStandardPropertyReferenceOfZodbPropertySheet(self):
""" """
Take the test Property Sheet, change the 'reference' field of a Take the test Property Sheet, change the 'reference' field of a
Standard Property and check that the accessor name has changed Standard Property and check that the accessor name has changed
Interaction: PropertySheet_resetDynamicClasses (manage_renameObject)
""" """
self._checkChangePropertyOfZodbPropertySheet( self._checkChangePropertyReferenceOfZodbPropertySheet(
self.test_standard_property_change.setReference, self.test_standard_property_change_reference.setReference,
'test_standard_property_change_renamed', 'test_standard_property_change_reference_renamed',
'getTestStandardPropertyChangeRenamed') 'getTestStandardPropertyChangeReferenceRenamed')
def testChangeAcquiredPropertyOfZodbPropertySheet(self): def testChangeAcquiredPropertyReferenceOfZodbPropertySheet(self):
""" """
Take the test Property Sheet, change the 'reference' field of an Take the test Property Sheet, change the 'reference' field of an
Acquired Property and check that the accessor name has changed Acquired Property and check that the accessor name has changed
Interaction: PropertySheet_resetDynamicClasses (manage_renameObject)
""" """
self._checkChangePropertyOfZodbPropertySheet( self._checkChangePropertyReferenceOfZodbPropertySheet(
self.test_acquired_property_change.setReference, self.test_acquired_property_change_reference.setReference,
'test_acquired_property_change_renamed', 'test_acquired_property_change_reference_renamed',
'getDefaultTestAcquiredPropertyChangeRenamedStreetAddress') 'getDefaultTestAcquiredPropertyChangeReferenceRenamedStreetAddress')
def testChangeCategoryPropertyOfZodbPropertySheet(self): def testChangeCategoryPropertyReferenceOfZodbPropertySheet(self):
""" """
Take the test Property Sheet, change the 'id' field of a Category Take the test Property Sheet, change the 'id' field of a Category Property
Property to another existing category and check that the accessor to another existing category and check that the accessor name has changed.
name has changed
Interaction: PropertySheet_resetDynamicClasses (manage_renameObject)
""" """
self._checkChangePropertyOfZodbPropertySheet( self._checkChangePropertyReferenceOfZodbPropertySheet(
self.test_category_property_change.setReference, self.test_category_property_change_reference.setReference,
'test_category_property_change_renamed', 'test_category_property_change_reference_renamed',
'getTestCategoryPropertyChangeRenamed') 'getTestCategoryPropertyChangeReferenceRenamed')
def testChangeDynamicCategoryPropertyOfZodbPropertySheet(self): def testChangeDynamicCategoryPropertyReferenceOfZodbPropertySheet(self):
""" """
Take the test Property Sheet, change the 'category_expression' Take the test Property Sheet, change the 'category_expression'
field of a Dynamic Category Property to another existing category field of a Dynamic Category Property to another existing category
and check that the accessor name has changed and check that the accessor name has changed
Interaction: PropertySheet_resetDynamicClasses (manage_renameObject)
"""
self._checkChangePropertyReferenceOfZodbPropertySheet(
self.test_dynamic_category_property_change_reference.setCategoryExpression,
"python: ('test_dynamic_category_property_change_reference_renamed',)",
'getTestDynamicCategoryPropertyChangeReferenceRenamed')
def _checkChangePropertyOfZodbPropertySheet(self,
property_obj,
accessor_name):
import erp5.accessor_holder.property_sheet
self.failIfHasAttribute(erp5.accessor_holder.property_sheet,
'TestMigration')
property_obj.setReadPermission('Manage Portal')
self._forceTestAccessorHolderGeneration()
self.assertHasAttribute(erp5.accessor_holder.property_sheet,
'TestMigration')
accessor_holder = erp5.accessor_holder.property_sheet.TestMigration
permission_accessor_tuple = dict(accessor_holder.__ac_permissions__).get(
'Manage Portal', ())
self.assertTrue(
accessor_name in permission_accessor_tuple,
msg="'%s' not found in 'Manage Portal' Permission tuple: %r" % (
accessor_name,
permission_accessor_tuple))
def testChangeStandardPropertyOfZodbPropertySheet(self):
"""
Take the test Property Sheet, change the 'read_permission' field of a
Standard Property and check that the accessor Permission has been changed
Interaction: ChangeProperty_resetDynamicClasses
"""
self._checkChangePropertyOfZodbPropertySheet(
self.test_standard_property_change,
'getTestStandardPropertyChange')
def testChangeAcquiredPropertyOfZodbPropertySheet(self):
"""
Take the test Property Sheet, change the 'read_permission' field of an
Acquired Property and check that the accessor Permission has been changed
Interaction: ChangeProperty_resetDynamicClasses
""" """
self._checkChangePropertyOfZodbPropertySheet( self._checkChangePropertyOfZodbPropertySheet(
self.test_dynamic_category_property_change.setCategoryExpression, self.test_acquired_property_change,
"python: ('test_dynamic_category_property_change_renamed',)", 'getTestAcquiredPropertyChange')
'getTestDynamicCategoryPropertyChangeRenamed')
def _checkDeletePropertyFromZodbPropertySheet(self, def _checkDeletePropertyFromZodbPropertySheet(self,
property_id, 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