Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions | Static Private Attributes
PluggableAuthService.tests.test_UserPropertySheet.UserPropertySheetTests Class Reference
Inheritance diagram for PluggableAuthService.tests.test_UserPropertySheet.UserPropertySheetTests:
Inheritance graph
[legend]
Collaboration diagram for PluggableAuthService.tests.test_UserPropertySheet.UserPropertySheetTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_ctor_id_noschema_novalues
def test_ctor__guessSchema
def test_ctor_w_schema
def test_ctor_w_schema_no_values

Private Member Functions

def _getTargetClass
def _makeOne
def _checkStockSchema

Static Private Attributes

tuple _SCHEMA
string _STRING_VALUE = 'string'
int _INT_VALUE = 42
float _FLOAT_VALUE = 9.8
int _LONG_VALUE = 1000000000000
tuple _DATE_VALUE = DateTime()
list _LIST_VALUE = [ 'a', 'b', 'c' ]
tuple _TUPLE_VALUE = ( 'd', 'e', 'f' )
 _BOOL_VALUE = True
tuple _IMG_VALUE = Image('image', 'Test Image', img_file)

Detailed Description

Definition at line 29 of file test_UserPropertySheet.py.


Member Function Documentation

def PluggableAuthService.tests.test_UserPropertySheet.UserPropertySheetTests._checkStockSchema (   self,
  ups,
  values_are_none = False 
) [private]

Definition at line 82 of file test_UserPropertySheet.py.

00082 
00083     def _checkStockSchema( self, ups, values_are_none=False ):
00084 
00085         self.failIf( ups.hasProperty( 'x' ) )
00086         self.failUnless( ups.hasProperty( 's' ) )
00087         self.failUnless( ups.hasProperty( 'i' ) )
00088         self.failUnless( ups.hasProperty( 'f' ) )
00089         self.failUnless( ups.hasProperty( 'n' ) )
00090         self.failUnless( ups.hasProperty( 'd' ) )
00091         self.failUnless( ups.hasProperty( 'l' ) )
00092         self.failUnless( ups.hasProperty( 't' ) )
00093         self.failUnless( ups.hasProperty( 'b' ) )
00094         self.failUnless( ups.hasProperty( 'img' ) )
00095 
00096         self.assertEqual( ups.getPropertyType( 's' ), 'string' )
00097         self.assertEqual( ups.propertyInfo( 's' )[ 'type' ], 'string' )
00098         if values_are_none:
00099             self.assertEqual( ups.getProperty( 's' ), None )
00100         else:
00101             self.assertEqual( ups.getProperty( 's' ), self._STRING_VALUE )
00102 
00103         self.assertEqual( ups.getPropertyType( 'i' ), 'int' )
00104         self.assertEqual( ups.propertyInfo( 'i' )[ 'type' ], 'int' )
00105         if values_are_none:
00106             self.assertEqual( ups.getProperty( 'i' ), None )
00107         else:
00108             self.assertEqual( ups.getProperty( 'i' ), self._INT_VALUE )
00109 
00110         self.assertEqual( ups.getPropertyType( 'f' ), 'float' )
00111         self.assertEqual( ups.propertyInfo( 'f' )[ 'type' ], 'float' )
00112         if values_are_none:
00113             self.assertEqual( ups.getProperty( 'f' ), None )
00114         else:
00115             self.assertEqual( ups.getProperty( 'f' ), self._FLOAT_VALUE )
00116 
00117         self.assertEqual( ups.getPropertyType( 'n' ), 'long' )
00118         self.assertEqual( ups.propertyInfo( 'n' )[ 'type' ], 'long' )
00119         if values_are_none:
00120             self.assertEqual( ups.getProperty( 'n' ), None )
00121         else:
00122             self.assertEqual( ups.getProperty( 'n' ), self._LONG_VALUE )
00123 
00124         self.assertEqual( ups.getPropertyType( 'd' ), 'date' )
00125         self.assertEqual( ups.propertyInfo( 'd' )[ 'type' ], 'date' )
00126         if values_are_none:
00127             self.assertEqual( ups.getProperty( 'd' ), None )
00128         else:
00129             self.assertEqual( ups.getProperty( 'd' ), self._DATE_VALUE )
00130 
00131         self.assertEqual( ups.getPropertyType( 'b' ), 'boolean' )
00132         self.assertEqual( ups.propertyInfo( 'b' )[ 'type' ], 'boolean' )
00133         if values_are_none:
00134             self.assertEqual( ups.getProperty( 'b' ), None )
00135         else:
00136             self.assertEqual( ups.getProperty( 'b' ), self._BOOL_VALUE )
00137 
00138         self.assertEqual( ups.getPropertyType( 'l' ), 'lines' )
00139         self.assertEqual( ups.propertyInfo( 'l' )[ 'type' ], 'lines' )
00140 
00141         if values_are_none:
00142             self.assertEqual( ups.getProperty( 'l' ), None )
00143         else:
00144             got = ups.getProperty( 'l' )
00145             self.assertEqual( type( got ), type( () ) )
00146             self.assertEqual( len( got ), len( self._LIST_VALUE ) )
00147 
00148             for i in range( len( self._LIST_VALUE ) ):
00149                 self.assertEqual( got[i], self._LIST_VALUE[i] )
00150 
00151         self.assertEqual( ups.getPropertyType( 't' ), 'lines' )
00152         self.assertEqual( ups.propertyInfo( 't' )[ 'type' ], 'lines' )
00153 
00154         if values_are_none:
00155             self.assertEqual( ups.getProperty( 't' ), None )
00156         else:
00157             got = ups.getProperty( 't' )
00158             self.assertEqual( type( got ), type( () ) )
00159             self.assertEqual( len( got ), len( self._TUPLE_VALUE ) )
00160 
00161             for i in range( len( self._TUPLE_VALUE ) ):
00162                 self.assertEqual( got[i], self._TUPLE_VALUE[i] )
00163 
00164         self.assertEqual( ups.getPropertyType( 'img' ), 'image' )
00165         self.assertEqual( ups.propertyInfo( 'img' )[ 'type' ], 'image' )
00166 
00167         if values_are_none:
00168             self.assertEqual( ups.getProperty( 'img' ), None )
00169         else:
00170             got = ups.getProperty( 'img' )
00171             self.assertEqual( type( got ), Image )
00172             self.assertEqual( got.size, self._IMG_VALUE.size )
00173             self.assertEqual( got, self._IMG_VALUE )
00174 
00175 
00176         pmap = ups.propertyMap()
00177         self.assertEqual( len( pmap ), len( self._SCHEMA ) )
00178 
00179         for i in range( len( pmap ) ):
00180             info = pmap[i]
00181             spec = [ x for x in self._SCHEMA if x[0] == info['id' ] ][0]
00182             self.assertEqual( info[ 'id' ], spec[0] )
00183             self.assertEqual( info[ 'type' ], spec[1] )
00184             self.assertEqual( info[ 'mode' ], '' )  # readonly, no delete
00185 

Here is the caller graph for this function:

Definition at line 52 of file test_UserPropertySheet.py.

00052 
00053     def _getTargetClass( self ):
00054 
00055         from Products.PluggableAuthService.UserPropertySheet \
00056             import UserPropertySheet
00057 
00058         return UserPropertySheet

Definition at line 59 of file test_UserPropertySheet.py.

00059 
00060     def _makeOne( self, *args, **kw ):
00061 
00062         return self._getTargetClass()( *args, **kw )

Definition at line 186 of file test_UserPropertySheet.py.

00186 
00187     def test_ctor__guessSchema( self ):
00188 
00189         ups = self._makeOne( 'guessed'
00190                            , s=self._STRING_VALUE
00191                            , i=self._INT_VALUE
00192                            , f=self._FLOAT_VALUE
00193                            , n=self._LONG_VALUE
00194                            , d=self._DATE_VALUE
00195                            , l=self._LIST_VALUE
00196                            , t=self._TUPLE_VALUE
00197                            , b=self._BOOL_VALUE
00198                            , img=self._IMG_VALUE
00199                            )
00200 
00201         self._checkStockSchema( ups )
00202 

Definition at line 63 of file test_UserPropertySheet.py.

00063 
00064     def test_ctor_id_noschema_novalues( self ):
00065 
00066         ups = self._makeOne( 'empty' )
00067 
00068         self.assertEqual( ups.getId(), 'empty' )
00069 
00070         self.failIf( ups.hasProperty( 'empty' ) )
00071         self.failIf( ups.hasProperty( 'foo' ) )
00072         self.failIf( ups.hasProperty( 'bar' ) )
00073 
00074         self.assertEqual( ups.getProperty( 'foo' ), None )
00075         self.assertEqual( ups.getPropertyType( 'foo' ), None )
00076 
00077         self.assertEqual( len( ups.propertyMap() ), 0 )
00078         self.assertEqual( len( ups.propertyIds() ), 0 )
00079         self.assertEqual( len( ups.propertyValues() ), 0 )
00080         self.assertEqual( len( ups.propertyItems() ), 0 )
00081         self.assertEqual( len( ups.propertyIds() ), 0 )

Definition at line 203 of file test_UserPropertySheet.py.

00203 
00204     def test_ctor_w_schema(self):
00205 
00206         ups = self._makeOne( 'w_schema'
00207                            , self._SCHEMA
00208                            , s=self._STRING_VALUE
00209                            , i=self._INT_VALUE
00210                            , f=self._FLOAT_VALUE
00211                            , n=self._LONG_VALUE
00212                            , d=self._DATE_VALUE
00213                            , l=self._LIST_VALUE
00214                            , t=self._TUPLE_VALUE
00215                            , b=self._BOOL_VALUE
00216                            , img=self._IMG_VALUE
00217                            )
00218 
00219         self._checkStockSchema( ups )
00220 

Definition at line 221 of file test_UserPropertySheet.py.

00221 
00222     def test_ctor_w_schema_no_values(self):
00223 
00224         ups = self._makeOne( 'w_schema'
00225                            , self._SCHEMA
00226                            )
00227 
00228         self._checkStockSchema( ups, values_are_none=True )


Member Data Documentation

Definition at line 49 of file test_UserPropertySheet.py.

Definition at line 46 of file test_UserPropertySheet.py.

Definition at line 44 of file test_UserPropertySheet.py.

Definition at line 50 of file test_UserPropertySheet.py.

Definition at line 43 of file test_UserPropertySheet.py.

Definition at line 47 of file test_UserPropertySheet.py.

Definition at line 45 of file test_UserPropertySheet.py.

Initial value:
( ( 's', 'string'  )
              , ( 'i', 'int'     )
              , ( 'f', 'float'   )
              , ( 'n', 'long'    )
              , ( 'd', 'date'    )
              , ( 'l', 'lines'   )
              , ( 't', 'lines'   )
              , ( 'b', 'boolean' )
              , ( 'img', 'image' )
              )

Definition at line 31 of file test_UserPropertySheet.py.

Definition at line 42 of file test_UserPropertySheet.py.

Definition at line 48 of file test_UserPropertySheet.py.


The documentation for this class was generated from the following file: