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

Florent Guillaume fg at nuxeo.com
Fri Jul 8 10:38:18 EDT 2005


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

Modified Files:
      Tag: CMF-1_5-branch
	test_utils.py 
Log Message:
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.4.2.5 => 1.4.2.6 ===
--- CMF/CMFSetup/tests/test_utils.py:1.4.2.5	Fri Jul  8 09:24:32 2005
+++ CMF/CMFSetup/tests/test_utils.py	Fri Jul  8 10:38:17 2005
@@ -50,6 +50,7 @@
             select_variable="foobarbaz">
    <element value="Foo"/>
    <element value="Baz"/></property>
+  <property name="foo_boolean0" type="boolean">0</property>
 """
 
 _FIXED_PROPERTY_NODES = """\
@@ -72,6 +73,7 @@
   <property name="foo_mselection">
    <element value="Foo"/>
    <element value="Baz"/></property>
+  <property name="foo_boolean0">0</property>
 """
 
 _NORMAL_PROPERTY_INFO = ( { 'id': 'foo_boolean',
@@ -128,7 +130,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"?>
@@ -255,6 +263,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')
@@ -268,6 +277,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
 
@@ -359,7 +369,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' )
@@ -435,6 +445,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()
@@ -480,7 +496,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