[CMF-checkins] CVS: CMF/CMFSetup/tests - test_utils.py:1.10

Florent Guillaume fg at nuxeo.com
Fri Jul 8 10:40:17 EDT 2005


Update of /cvs-repository/CMF/CMFSetup/tests
In directory cvs.zope.org:/tmp/cvs-serv32762/tests

Modified Files:
	test_utils.py 
Log Message:
Merge from 1.5 branch:
Make sure a '0' boolean is imported as False.
A '0' boolean can occur if a boolean property containing 0 is exported.


=== CMF/CMFSetup/tests/test_utils.py 1.9 => 1.10 ===
--- CMF/CMFSetup/tests/test_utils.py:1.9	Wed Jun 15 10:17:39 2005
+++ CMF/CMFSetup/tests/test_utils.py	Fri Jul  8 10:40:16 2005
@@ -47,6 +47,7 @@
             select_variable="foobarbaz">
    <element value="Foo"/>
    <element value="Baz"/></property>
+  <property name="foo_boolean0" type="boolean">0</property>
 """
 
 _FIXED_PROPERTY_NODES = """\
@@ -69,6 +70,7 @@
   <property name="foo_mselection">
    <element value="Foo"/>
    <element value="Baz"/></property>
+  <property name="foo_boolean0">0</property>
 """
 
 _NORMAL_PROPERTY_INFO = ( { 'id': 'foo_boolean',
@@ -125,7 +127,13 @@
                             'value': '',
                             'elements': ('Foo', 'Baz'),
                             'type': 'multiple selection',
-                            'select_variable': 'foobarbaz' } )
+                            'select_variable': 'foobarbaz' },
+                          { 'id': 'foo_boolean0',
+                            'value': False, # 0 imports as False
+                            'elements': (),
+                            'type': 'boolean',
+                            'select_variable': None },
+                          )
 
 _NORMAL_PROPERTY_EXPORT = """\
 <?xml version="1.0"?>
@@ -252,6 +260,7 @@
             site.dummy._setProperty('foo_selection', 'foobarbaz', 'selection')
             site.dummy._setProperty('foo_mselection', 'foobarbaz',
                                     'multiple selection')
+            site.dummy._setProperty('foo_boolean0', '', 'boolean')
 
         if foo > 1:
             site.dummy._updateProperty('foo_boolean', 'True')
@@ -265,6 +274,7 @@
             site.dummy._updateProperty( 'foo_tokens', ('Foo', 'Tokens') )
             site.dummy._updateProperty('foo_selection', 'Foo')
             site.dummy._updateProperty( 'foo_mselection', ('Foo', 'Baz') )
+            site.dummy.foo_boolean0 = 0
 
         return site
 
@@ -356,7 +366,7 @@
         configurator = self._makeOne(site)
         site_info = configurator.parseXML(_NORMAL_PROPERTY_EXPORT)
 
-        self.assertEqual( len( site_info['properties'] ), 11 )
+        self.assertEqual( len( site_info['properties'] ), 12 )
 
         info = site_info['properties'][0]
         self.assertEqual( info['id'], 'foo_boolean' )
@@ -432,6 +442,12 @@
         self.assertEqual( info['type'], 'multiple selection' )
         self.assertEqual( info['select_variable'], 'foobarbaz' )
 
+        info = site_info['properties'][11]
+        self.assertEqual( info['id'], 'foo_boolean0' )
+        self.assertEqual( info['value'], '0' )
+        self.assertEqual( len( info['elements'] ), 0 )
+        self.assertEqual( info['type'], 'boolean' )
+
     def test_parseXML_special(self):
 
         site = self._initSite()
@@ -477,7 +493,7 @@
         configurator = self._makeOne(site)
         site_info = configurator.parseXML(_FIXED_PROPERTY_EXPORT)
 
-        self.assertEqual( len( dummy.propertyIds() ), 11 )
+        self.assertEqual( len( dummy.propertyIds() ), 12 )
 
         for prop_info in site_info['properties']:
             configurator.initProperty(dummy, prop_info)



More information about the CMF-checkins mailing list