From 75c632c65deaa1757e508eba877bc2b1ab578021 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Wed, 10 Oct 2007 09:19:48 +0000
Subject: [PATCH] Add test for "lines" properties accessors and default values.
 Remove empty test on "bang accessor", it apparently no longer exists.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16926 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/tests/testERP5Type.py | 41 +++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/product/ERP5Type/tests/testERP5Type.py b/product/ERP5Type/tests/testERP5Type.py
index 4401667eff..1a5ea4312c 100644
--- a/product/ERP5Type/tests/testERP5Type.py
+++ b/product/ERP5Type/tests/testERP5Type.py
@@ -769,13 +769,6 @@ class TestPropertySheet:
       # which is one step higher in the site 
       pass
 
-    def test_14_bangAccessor(self, quiet=quiet, run=run_all_test):
-      """
-      Bang accesors must be triggered each time another accessor is called
-      They are useful for centralising events ?
-      """
-      pass
-
     def test_15_DefaultValue(self):
       """
       Tests that the default value is returned correctly
@@ -844,6 +837,40 @@ class TestPropertySheet:
       self.assertEquals(value, person.getProperty('dummy_ps_prop'))
       self.assertEquals(value, person.getProperty('dummy_ps_prop', d='default'))
 
+
+    def test_15b_ListAccessorsDefaultValueDefinedOnPropertySheet(self):
+      """Tests that the default value is returned correctly when a default
+      value is defined using the property sheet, on list accesors.
+      """
+      self._addProperty('Person', '''{'id': 'dummy_ps_prop',
+                                      'type': 'lines',
+                                      'mode': 'w',
+                                      'default': [1, 2, 3],}''')
+      module = self.getPersonModule()
+      person = module.newContent(id='1', portal_type='Person')
+      # default accessor and list accessors are generated
+      self.assertTrue(hasattr(person, 'getDummyPsProp'))
+      self.assertTrue(hasattr(person, 'getDummyPsPropList'))
+
+      # The default ps value will be returned, when using generated accessor
+      self.assertEquals([1, 2, 3], person.getDummyPsPropList())
+      # (unless you explicitly pass a default value.
+      self.assertEquals(['default'], person.getDummyPsPropList(['default']))
+      # using getProperty
+      self.assertEquals([1, 2, 3], person.getProperty('dummy_ps_prop_list'))
+      self.assertEquals(['default'],
+                        person.getProperty('dummy_ps_prop_list', ['default']))
+
+      # once the value has been set, there's no default
+      value_list = ['some', 'values']
+      person.setDummyPsPropList(value_list)
+      self.assertEquals(value_list, person.getDummyPsPropList())
+      self.assertEquals(value_list, person.getDummyPsPropList(['default']))
+      self.assertEquals(value_list, person.getProperty('dummy_ps_prop_list'))
+      self.assertEquals(value_list,
+              person.getProperty('dummy_ps_prop_list', d=['default']))
+
+
     def test_15c_getDescriptionDefaultValue(self):
       """
       Tests that the default value of getDescription is returned correctly
-- 
2.30.9