From 0f2379665527a320174c56a4c99aa17bdc1ac39d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Mon, 9 Feb 2009 10:11:55 +0000 Subject: [PATCH] tests for setProperty of type list for local properties git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25497 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/tests/testBase.py | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/product/ERP5/tests/testBase.py b/product/ERP5/tests/testBase.py index 74bf37cf4e..11ff6133b0 100644 --- a/product/ERP5/tests/testBase.py +++ b/product/ERP5/tests/testBase.py @@ -883,6 +883,24 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): obj.edit(**{property_name: property_value}) self.assertEquals(obj.getProperty(property_name), property_value) + def test_10_setPropertyListNotDefinedProperty(self, quiet=quiet, + run=run_all_test): + """Test for setProperty for a list on Base, when the property is not defined. + """ + if not run: return + portal = self.getPortal() + portal_type = "Organisation" + module = portal.getDefaultModule(portal_type=portal_type) + obj = module.newContent(portal_type=portal_type) + property_value = ('1', '2') + property_name = 'a_dummy_not_exising_property_list' + obj.setProperty(property_name, property_value) + self.assertEquals(obj.getProperty(property_name), property_value) + obj.setProperty(property_name, property_value) + self.assertEquals(obj.getProperty(property_name), property_value) + obj.edit(**{property_name: property_value}) + self.assertEquals(obj.getProperty(property_name), property_value) + def test_11_setPropertyPropertyDefinedOnInstance(self, quiet=quiet, run=run_all_test): """Test for setProperty on Base, when the property is defined on the @@ -1131,6 +1149,26 @@ class TestERP5PropertyManager(unittest.TestCase): self.assertEquals(type(ob.getProperty('a_second_dummy_property')), type(DateTime())) + def test_setPropertyTypeLines(self): + ob = self._makeOne('ob') + ob._setProperty('a_dummy_list_property', ('1', '2'), type='lines') + self.assertEquals(['lines'], [x['type'] for x in ob.propertyMap() + if x['id'] == 'a_dummy_list_property']) + self.assertEquals(ob.getProperty('a_dummy_list_property'), ('1', '2')) + + #Set Property without type argument + ob._setProperty('a_second_dummy_property_list', ('3', '4')) + self.assertEquals(['lines'], [x['type'] for x in ob.propertyMap() + if x['id'] == 'a_second_dummy_property_list']) + self.assertEquals(ob.getProperty('a_second_dummy_property_list'), + ('3', '4')) + # same, but passing a list, not a tuple + ob._setProperty('a_third_dummy_property_list', ['5', '6']) + self.assertEquals(['lines'], [x['type'] for x in ob.propertyMap() + if x['id'] == 'a_third_dummy_property_list']) + self.assertEquals(ob.getProperty('a_third_dummy_property_list'), + ('5', '6')) + def test_getPropertyNonExistantProps(self): """getProperty return None if the value is not found. """ -- 2.30.9