Commit 9e98bfd4 authored by Sebastien Robin's avatar Sebastien Robin

* getter on a undefined list property was not working properly

  any more, bug was introduced by revision 25485
* add unit test to prevent such regression


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25498 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0f237966
...@@ -1378,10 +1378,9 @@ class Base( CopyContainer, ...@@ -1378,10 +1378,9 @@ class Base( CopyContainer,
if not isinstance(result, (list, tuple)): if not isinstance(result, (list, tuple)):
result = [result] result = [result]
return result return result
else: if d is not _MARKER:
if d is not _MARKER: return ERP5PropertyManager.getProperty(self, key, d=d, **kw)
return ERP5PropertyManager.getProperty(self, key, d=d, **kw) return ERP5PropertyManager.getProperty(self, key, **kw)
return ERP5PropertyManager.getProperty(self, key, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getPropertyList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getPropertyList' )
def getPropertyList(self, key, d=None): def getPropertyList(self, key, d=None):
......
...@@ -2583,6 +2583,19 @@ class TestPropertySheet: ...@@ -2583,6 +2583,19 @@ class TestPropertySheet:
person.setPropertyList('foo_bar', []) person.setPropertyList('foo_bar', [])
self.assertEquals(person.getFooBarList(), []) self.assertEquals(person.getFooBarList(), [])
def testUndefinedProperties(self):
"""
Make sure that getProperty and setProperty on a property not defined
in a propertysheet is working properly.
"""
person = self.getPersonModule().newContent(portal_type='Person')
self.assertEquals(person.getProperty('foo_bar'), None)
person.setProperty('foo_bar', 'foo')
self.assertEquals(person.getProperty('foo_bar'), 'foo')
self.assertEquals(person.getPropertyList('foo_bar_list'), None)
person.setProperty('foo_bar_list', ['foo', 'bar'])
self.assertEquals(list(person.getProperty('foo_bar_list')), ['foo', 'bar'])
class TestAccessControl(ERP5TypeTestCase): class TestAccessControl(ERP5TypeTestCase):
# Isolate test in a dedicaced class in order not to break other tests # Isolate test in a dedicaced class in order not to break other tests
# when this one fails. # when this one fails.
......
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