Commit 3dab2e92 authored by Łukasz Nowak's avatar Łukasz Nowak

Ignore no local properties while fixing.

parent 89f275b4
......@@ -81,6 +81,7 @@ class PropertyTypeValidity(Constraint):
error_list = []
# For each attribute name, we check type
for prop in obj.propertyMap():
property_was_local = False
property_id = prop['id']
if prop.get('multivalued', 0):
property_type = 'lines'
......@@ -95,6 +96,7 @@ class PropertyTypeValidity(Constraint):
len([x for x in obj._propertyMap() if x['id'] == property_id]) > 1:
obj._local_properties = tuple([x for x in obj._local_properties
if x['id'] != property_id])
property_was_local = True
if property_type in self._permissive_type_list:
continue
......@@ -135,7 +137,7 @@ class PropertyTypeValidity(Constraint):
error_list.append(self._generateError(obj,
self._getMessage(error_message), mapping))
elif fixit:
elif fixit and property_was_local:
oldvalue = getattr(obj, property_id, value)
if oldvalue != value:
error_list.append(self._generateError(obj,
......
......@@ -1178,6 +1178,27 @@ class TestConstraint(PropertySheetTestCase):
expression='error: " ')
self.assertRaises(CompilerError, constraint.checkConsistency, obj)
def test_PropertyTypeValidityFixLocalPropertiesIgnoresNoLocal(self):
"""Tests PropertyTypeValidity can repairs local property when this property
is added on the class later, and this property is already in the good type.
"""
constraint = self._createGenericConstraint(
klass_name='PropertyTypeValidity',
id='type_validity_constraint', )
obj = self._makeOne()
self._addProperty(obj.getPortalType(), "FixLocalPropertiesString",
portal_type="Standard Property",
property_id="local_property",
elementary_type="string")
obj.edit(local_property='1')
self.assertFalse('_local_properties' in obj.__dict__)
self.assertEquals([], constraint.checkConsistency(obj))
self.assertEqual([], constraint.fixConsistency(obj))
self.assertFalse('_local_properties' in obj.__dict__)
self.assertEquals('1', obj.getLocalProperty())
obj.edit(local_property='something else')
self.assertEquals('something else', obj.getLocalProperty())
def test_PropertyTypeValidityFixLocalPropertiesString(self):
"""Tests PropertyTypeValidity can repairs local property when this property
is added on the class later, and this property is already in the good type.
......
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