[Checkins] SVN: PluggableAuthService/branches/1.4/ #50: Don't barf on None as initial value for 'lines' properties.

Tres Seaver tseaver at palladion.com
Tue Apr 24 12:53:31 EDT 2007


Log message for revision 74709:
  #50:  Don't barf on None as initial value for 'lines' properties.

Changed:
  U   PluggableAuthService/branches/1.4/UserPropertySheet.py
  U   PluggableAuthService/branches/1.4/doc/CHANGES.txt
  U   PluggableAuthService/branches/1.4/tests/test_UserPropertySheet.py

-=-
Modified: PluggableAuthService/branches/1.4/UserPropertySheet.py
===================================================================
--- PluggableAuthService/branches/1.4/UserPropertySheet.py	2007-04-24 16:37:39 UTC (rev 74708)
+++ PluggableAuthService/branches/1.4/UserPropertySheet.py	2007-04-24 16:53:31 UTC (rev 74709)
@@ -106,7 +106,8 @@
             value = kw.get( id )
 
             if ptype == 'lines':
-                value = tuple( value )
+                if value is not None:
+                    value = tuple( value )
 
             self._properties[ id ] = value
 

Modified: PluggableAuthService/branches/1.4/doc/CHANGES.txt
===================================================================
--- PluggableAuthService/branches/1.4/doc/CHANGES.txt	2007-04-24 16:37:39 UTC (rev 74708)
+++ PluggableAuthService/branches/1.4/doc/CHANGES.txt	2007-04-24 16:53:31 UTC (rev 74709)
@@ -4,6 +4,9 @@
 
     Bugs Fixed
 
+      - Handle 'None' as an initial value for 'lines' properties.
+        (http://www.zope.org/Collectors/PAS/50)
+
       - Fix ZODBUserManager plugin's 'manage_updatePassword', called when
         users update their own login / password.
         (http://www.zope.org/Collectors/PAS/56)

Modified: PluggableAuthService/branches/1.4/tests/test_UserPropertySheet.py
===================================================================
--- PluggableAuthService/branches/1.4/tests/test_UserPropertySheet.py	2007-04-24 16:37:39 UTC (rev 74708)
+++ PluggableAuthService/branches/1.4/tests/test_UserPropertySheet.py	2007-04-24 16:53:31 UTC (rev 74709)
@@ -70,7 +70,7 @@
         self.assertEqual( len( ups.propertyItems() ), 0 )
         self.assertEqual( len( ups.propertyIds() ), 0 )
 
-    def _checkStockSchema( self, ups ):
+    def _checkStockSchema( self, ups, values_are_none=False ):
 
         self.failIf( ups.hasProperty( 'x' ) )
         self.failUnless( ups.hasProperty( 's' ) )
@@ -84,47 +84,71 @@
 
         self.assertEqual( ups.getPropertyType( 's' ), 'string' )
         self.assertEqual( ups.propertyInfo( 's' )[ 'type' ], 'string' )
-        self.assertEqual( ups.getProperty( 's' ), self._STRING_VALUE )
+        if values_are_none:
+            self.assertEqual( ups.getProperty( 's' ), None )
+        else:
+            self.assertEqual( ups.getProperty( 's' ), self._STRING_VALUE )
 
         self.assertEqual( ups.getPropertyType( 'i' ), 'int' )
         self.assertEqual( ups.propertyInfo( 'i' )[ 'type' ], 'int' )
-        self.assertEqual( ups.getProperty( 'i' ), self._INT_VALUE )
+        if values_are_none:
+            self.assertEqual( ups.getProperty( 'i' ), None )
+        else:
+            self.assertEqual( ups.getProperty( 'i' ), self._INT_VALUE )
 
         self.assertEqual( ups.getPropertyType( 'f' ), 'float' )
         self.assertEqual( ups.propertyInfo( 'f' )[ 'type' ], 'float' )
-        self.assertEqual( ups.getProperty( 'f' ), self._FLOAT_VALUE )
+        if values_are_none:
+            self.assertEqual( ups.getProperty( 'f' ), None )
+        else:
+            self.assertEqual( ups.getProperty( 'f' ), self._FLOAT_VALUE )
 
         self.assertEqual( ups.getPropertyType( 'n' ), 'long' )
         self.assertEqual( ups.propertyInfo( 'n' )[ 'type' ], 'long' )
-        self.assertEqual( ups.getProperty( 'n' ), self._LONG_VALUE )
+        if values_are_none:
+            self.assertEqual( ups.getProperty( 'n' ), None )
+        else:
+            self.assertEqual( ups.getProperty( 'n' ), self._LONG_VALUE )
 
         self.assertEqual( ups.getPropertyType( 'd' ), 'date' )
         self.assertEqual( ups.propertyInfo( 'd' )[ 'type' ], 'date' )
-        self.assertEqual( ups.getProperty( 'd' ), self._DATE_VALUE )
+        if values_are_none:
+            self.assertEqual( ups.getProperty( 'd' ), None )
+        else:
+            self.assertEqual( ups.getProperty( 'd' ), self._DATE_VALUE )
 
         self.assertEqual( ups.getPropertyType( 'b' ), 'boolean' )
         self.assertEqual( ups.propertyInfo( 'b' )[ 'type' ], 'boolean' )
-        self.assertEqual( ups.getProperty( 'b' ), self._BOOL_VALUE )
+        if values_are_none:
+            self.assertEqual( ups.getProperty( 'b' ), None )
+        else:
+            self.assertEqual( ups.getProperty( 'b' ), self._BOOL_VALUE )
 
         self.assertEqual( ups.getPropertyType( 'l' ), 'lines' )
         self.assertEqual( ups.propertyInfo( 'l' )[ 'type' ], 'lines' )
 
-        got = ups.getProperty( 'l' )
-        self.assertEqual( type( got ), type( () ) )
-        self.assertEqual( len( got ), len( self._LIST_VALUE ) )
+        if values_are_none:
+            self.assertEqual( ups.getProperty( 'l' ), None )
+        else:
+            got = ups.getProperty( 'l' )
+            self.assertEqual( type( got ), type( () ) )
+            self.assertEqual( len( got ), len( self._LIST_VALUE ) )
 
-        for i in range( len( self._LIST_VALUE ) ):
-            self.assertEqual( got[i], self._LIST_VALUE[i] )
+            for i in range( len( self._LIST_VALUE ) ):
+                self.assertEqual( got[i], self._LIST_VALUE[i] )
 
         self.assertEqual( ups.getPropertyType( 't' ), 'lines' )
         self.assertEqual( ups.propertyInfo( 't' )[ 'type' ], 'lines' )
 
-        got = ups.getProperty( 't' )
-        self.assertEqual( type( got ), type( () ) )
-        self.assertEqual( len( got ), len( self._TUPLE_VALUE ) )
+        if values_are_none:
+            self.assertEqual( ups.getProperty( 't' ), None )
+        else:
+            got = ups.getProperty( 't' )
+            self.assertEqual( type( got ), type( () ) )
+            self.assertEqual( len( got ), len( self._TUPLE_VALUE ) )
 
-        for i in range( len( self._TUPLE_VALUE ) ):
-            self.assertEqual( got[i], self._TUPLE_VALUE[i] )
+            for i in range( len( self._TUPLE_VALUE ) ):
+                self.assertEqual( got[i], self._TUPLE_VALUE[i] )
 
         pmap = ups.propertyMap()
         self.assertEqual( len( pmap ), len( self._SCHEMA ) )
@@ -169,6 +193,15 @@
 
         self._checkStockSchema( ups )
 
+
+    def test_ctor_w_schema_no_values(self):
+
+        ups = self._makeOne( 'w_schema'
+                           , self._SCHEMA
+                           )
+
+        self._checkStockSchema( ups, values_are_none=True )
+
 if __name__ == "__main__":
     unittest.main()
 



More information about the Checkins mailing list