Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions
GenericSetup.tests.test_registry.ImportStepRegistryTests Class Reference
Inheritance diagram for GenericSetup.tests.test_registry.ImportStepRegistryTests:
Inheritance graph
[legend]
Collaboration diagram for GenericSetup.tests.test_registry.ImportStepRegistryTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_empty
def test_getStep_nonesuch
def test_getStep_defaulted
def test_registerStep_docstring
def test_registerStep_docstring_override
def test_registerStep_single
def test_registerStep_conflict
def test_registerStep_replacement
def test_registerStep_multiple
def test_sortStep_simple
def test_sortStep_chained
def test_sortStep_complex
def test_sortStep_equivalence
def test_checkComplete_simple
def test_checkComplete_double
def test_generateXML_empty
def test_generateXML_single
def test_generateXML_ordered
def test_parseXML_empty
def test_parseXML_single

Static Public Attributes

 layer = ExportImportZCMLLayer

Private Member Functions

def _getTargetClass

Detailed Description

Definition at line 59 of file test_registry.py.


Member Function Documentation

Definition at line 63 of file test_registry.py.

00063 
00064     def _getTargetClass( self ):
00065 
00066         from Products.GenericSetup.registry import ImportStepRegistry
00067         return ImportStepRegistry

Definition at line 397 of file test_registry.py.

00397 
00398     def test_checkComplete_double( self ):
00399 
00400         registry = self._makeOne()
00401 
00402         registry.registerStep( id='one'
00403                              , version='1'
00404                              , handler=ONE_FUNC
00405                              , dependencies=( 'two', 'three' )
00406                              )
00407 
00408         incomplete = registry.checkComplete()
00409         self.assertEqual( len( incomplete ), 2 )
00410         self.failUnless( ( 'one', 'two' ) in incomplete )
00411         self.failUnless( ( 'one', 'three' ) in incomplete )
00412 
00413         registry.registerStep( id='two'
00414                              , version='2'
00415                              , handler=TWO_FUNC
00416                              , dependencies=()
00417                              )
00418 
00419         incomplete = registry.checkComplete()
00420         self.assertEqual( len( incomplete ), 1 )
00421         self.failUnless( ( 'one', 'three' ) in incomplete )
00422 
00423         registry.registerStep( id='three'
00424                              , version='3'
00425                              , handler=THREE_FUNC
00426                              , dependencies=()
00427                              )
00428 
00429         self.assertEqual( len( registry.checkComplete() ), 0 )
00430 
00431         registry.registerStep( id='two'
00432                              , version='2.1'
00433                              , handler=TWO_FUNC
00434                              , dependencies=( 'four', )
00435                              )
00436 
00437         incomplete = registry.checkComplete()
00438         self.assertEqual( len( incomplete ), 1 )
00439         self.failUnless( ( 'two', 'four' ) in incomplete )

Definition at line 375 of file test_registry.py.

00375 
00376     def test_checkComplete_simple( self ):
00377 
00378         registry = self._makeOne()
00379 
00380         registry.registerStep( id='one'
00381                              , version='1'
00382                              , handler=ONE_FUNC
00383                              , dependencies=( 'two', )
00384                              )
00385 
00386         incomplete = registry.checkComplete()
00387         self.assertEqual( len( incomplete ), 1 )
00388         self.failUnless( ( 'one', 'two' ) in incomplete )
00389 
00390         registry.registerStep( id='two'
00391                              , version='2'
00392                              , handler=TWO_FUNC
00393                              , dependencies=()
00394                              )
00395 
00396         self.assertEqual( len( registry.checkComplete() ), 0 )

Definition at line 68 of file test_registry.py.

00068 
00069     def test_empty( self ):
00070 
00071         registry = self._makeOne()
00072 
00073         self.assertEqual( len( registry.listSteps() ), 0 )
00074         self.assertEqual( len( registry.listStepMetadata() ), 0 )
00075         self.assertEqual( len( registry.sortSteps() ), 0 )

Definition at line 440 of file test_registry.py.

00440 
00441     def test_generateXML_empty( self ):
00442 
00443         registry = self._makeOne().__of__(self.app)
00444 
00445         xml = registry.generateXML()
00446 
00447         self._compareDOM( registry.generateXML(), _EMPTY_IMPORT_XML )

Definition at line 462 of file test_registry.py.

00462 
00463     def test_generateXML_ordered( self ):
00464 
00465         registry = self._makeOne().__of__(self.app)
00466 
00467         registry.registerStep( id='one'
00468                              , version='1'
00469                              , handler=ONE_FUNC
00470                              , dependencies=( 'two', )
00471                              , title='One Step'
00472                              , description='One small step'
00473                              )
00474 
00475         registry.registerStep( id='two'
00476                              , version='2'
00477                              , handler=TWO_FUNC
00478                              , dependencies=( 'three', )
00479                              , title='Two Steps'
00480                              , description='Texas two step'
00481                              )
00482 
00483         registry.registerStep( id='three'
00484                              , version='3'
00485                              , handler=THREE_FUNC
00486                              , dependencies=()
00487                              , title='Three Steps'
00488                              , description='Gimme three steps'
00489                              )
00490 
00491         self._compareDOM( registry.generateXML(), _ORDERED_IMPORT_XML )

Definition at line 448 of file test_registry.py.

00448 
00449     def test_generateXML_single( self ):
00450 
00451         registry = self._makeOne().__of__(self.app)
00452 
00453         registry.registerStep( id='one'
00454                              , version='1'
00455                              , handler=ONE_FUNC
00456                              , dependencies=()
00457                              , title='One Step'
00458                              , description='One small step'
00459                              )
00460 
00461         self._compareDOM( registry.generateXML(), _SINGLE_IMPORT_XML )

Definition at line 89 of file test_registry.py.

00089 
00090     def test_getStep_defaulted( self ):
00091 
00092         registry = self._makeOne()
00093         default = object()
00094 
00095         self.failUnless( registry.getStep( 'nonesuch', default ) is default )
00096         self.assertEqual( registry.getStepMetadata( 'nonesuch', {} ), {} )

Definition at line 76 of file test_registry.py.

00076 
00077     def test_getStep_nonesuch( self ):
00078 
00079         registry = self._makeOne()
00080 
00081         self.assertEqual( registry.getStep( 'nonesuch' ), None )
00082         self.assertEqual( registry.getStep( 'nonesuch' ), None )
00083         default = object()
00084         self.failUnless( registry.getStepMetadata( 'nonesuch'
00085                                                  , default ) is default )
00086         self.failUnless( registry.getStep( 'nonesuch', default ) is default )
00087         self.failUnless( registry.getStepMetadata( 'nonesuch'
00088                                                  , default ) is default )

Definition at line 492 of file test_registry.py.

00492 
00493     def test_parseXML_empty( self ):
00494 
00495         registry = self._makeOne().__of__(self.app)
00496 
00497         registry.registerStep( id='one'
00498                              , version='1'
00499                              , handler=ONE_FUNC
00500                              , dependencies=()
00501                              , description='One small step'
00502                              )
00503 
00504         info_list = registry.parseXML( _EMPTY_IMPORT_XML )
00505 
00506         self.assertEqual( len( info_list ), 0 )

Definition at line 507 of file test_registry.py.

00507 
00508     def test_parseXML_single( self ):
00509 
00510         registry = self._makeOne().__of__(self.app)
00511 
00512         registry.registerStep( id='two'
00513                              , version='2'
00514                              , handler=TWO_FUNC
00515                              , dependencies=()
00516                              , title='Two Steps'
00517                              , description='Texas two step'
00518                              )
00519 
00520         info_list = registry.parseXML( _SINGLE_IMPORT_XML )
00521 
00522         self.assertEqual( len( info_list ), 1 )
00523 
00524         info = info_list[ 0 ]
00525         self.assertEqual( info[ 'id' ], 'one' )
00526         self.assertEqual( info[ 'version' ], '1' )
00527         self.assertEqual( info[ 'handler' ], ONE_FUNC_NAME )
00528         self.assertEqual( info[ 'dependencies' ], () )
00529         self.assertEqual( info[ 'title' ], 'One Step' )
00530         self.failUnless( 'One small step' in info[ 'description' ] )
00531 

Definition at line 161 of file test_registry.py.

00161 
00162     def test_registerStep_conflict( self ):
00163 
00164         registry = self._makeOne()
00165 
00166         registry.registerStep( id='one', version='1', handler=ONE_FUNC_NAME )
00167 
00168         self.assertRaises( KeyError
00169                          , registry.registerStep
00170                          , id='one'
00171                          , version='0'
00172                          , handler=ONE_FUNC
00173                          )
00174 
00175         registry.registerStep( id='one', version='1', handler=ONE_FUNC_NAME )
00176 
00177         info_list = registry.listStepMetadata()
00178         self.assertEqual( len( info_list ), 1 )

Definition at line 97 of file test_registry.py.

00097 
00098     def test_registerStep_docstring( self ):
00099 
00100         registry = self._makeOne()
00101 
00102         registry.registerStep( id='docstring'
00103                              , version='1'
00104                              , handler=DOC_FUNC
00105                              , dependencies=()
00106                              )
00107 
00108         info = registry.getStepMetadata( 'docstring' )
00109         self.assertEqual( info[ 'id' ], 'docstring' )
00110         self.assertEqual( info[ 'handler' ], DOC_FUNC_NAME )
00111         self.assertEqual( info[ 'dependencies' ], () )
00112         self.assertEqual( info[ 'title' ], 'This is the first line.' )
00113         self.assertEqual( info[ 'description' ] , 'This is the second line.' )

Definition at line 114 of file test_registry.py.

00114 
00115     def test_registerStep_docstring_override( self ):
00116 
00117         registry = self._makeOne()
00118 
00119         registry.registerStep( id='docstring'
00120                              , version='1'
00121                              , handler=DOC_FUNC
00122                              , dependencies=()
00123                              , title='Title'
00124                              )
00125 
00126         info = registry.getStepMetadata( 'docstring' )
00127         self.assertEqual( info[ 'id' ], 'docstring' )
00128         self.assertEqual( info[ 'handler' ], DOC_FUNC_NAME )
00129         self.assertEqual( info[ 'dependencies' ], () )
00130         self.assertEqual( info[ 'title' ], 'Title' )
00131         self.assertEqual( info[ 'description' ] , 'This is the second line.' )

Definition at line 206 of file test_registry.py.

00206 
00207     def test_registerStep_multiple( self ):
00208 
00209         registry = self._makeOne()
00210 
00211         registry.registerStep( id='one'
00212                              , version='1'
00213                              , handler=ONE_FUNC
00214                              , dependencies=()
00215                              )
00216 
00217         registry.registerStep( id='two'
00218                              , version='2'
00219                              , handler=TWO_FUNC
00220                              , dependencies=()
00221                              )
00222 
00223         registry.registerStep( id='three'
00224                              , version='3'
00225                              , handler=THREE_FUNC
00226                              , dependencies=()
00227                              )
00228 
00229         steps = registry.listSteps()
00230         self.assertEqual( len( steps ), 3 )
00231         self.failUnless( 'one' in steps )
00232         self.failUnless( 'two' in steps )
00233         self.failUnless( 'three' in steps )

Definition at line 179 of file test_registry.py.

00179 
00180     def test_registerStep_replacement( self ):
00181 
00182         registry = self._makeOne()
00183 
00184         registry.registerStep( id='one'
00185                              , version='1'
00186                              , handler=ONE_FUNC
00187                              , dependencies=( 'two', 'three' )
00188                              , title='One Step'
00189                              , description='One small step'
00190                              )
00191 
00192         registry.registerStep( id='one'
00193                              , version='1.1'
00194                              , handler=ONE_FUNC
00195                              , dependencies=()
00196                              , title='Leads to Another'
00197                              , description='Another small step'
00198                              )
00199 
00200         info = registry.getStepMetadata( 'one' )
00201         self.assertEqual( info[ 'id' ], 'one' )
00202         self.assertEqual( info[ 'version' ], '1.1' )
00203         self.assertEqual( info[ 'dependencies' ], () )
00204         self.assertEqual( info[ 'title' ], 'Leads to Another' )
00205         self.assertEqual( info[ 'description' ], 'Another small step' )

Definition at line 132 of file test_registry.py.

00132 
00133     def test_registerStep_single( self ):
00134 
00135         registry = self._makeOne()
00136 
00137         registry.registerStep( id='one'
00138                              , version='1'
00139                              , handler=ONE_FUNC
00140                              , dependencies=( 'two', 'three' )
00141                              , title='One Step'
00142                              , description='One small step'
00143                              )
00144 
00145         steps = registry.listSteps()
00146         self.assertEqual( len( steps ), 1 )
00147         self.failUnless( 'one' in steps )
00148         self.assertEqual( registry.getStep( 'one' ), ONE_FUNC )
00149 
00150         info = registry.getStepMetadata( 'one' )
00151         self.assertEqual( info[ 'id' ], 'one' )
00152         self.assertEqual( info[ 'version' ], '1' )
00153         self.assertEqual( info[ 'handler' ], ONE_FUNC_NAME )
00154         self.assertEqual( info[ 'dependencies' ], ( 'two', 'three' ) )
00155         self.assertEqual( info[ 'title' ], 'One Step' )
00156         self.assertEqual( info[ 'description' ], 'One small step' )
00157 
00158         info_list = registry.listStepMetadata()
00159         self.assertEqual( len( info_list ), 1 )
00160         self.assertEqual( info, info_list[ 0 ] )

Definition at line 257 of file test_registry.py.

00257 
00258     def test_sortStep_chained( self ):
00259 
00260         registry = self._makeOne()
00261 
00262         registry.registerStep( id='one'
00263                              , version='1'
00264                              , handler=ONE_FUNC
00265                              , dependencies=( 'three', )
00266                              , title='One small step'
00267                              )
00268 
00269         registry.registerStep( id='two'
00270                              , version='2'
00271                              , handler=TWO_FUNC
00272                              , dependencies=( 'one', )
00273                              , title='Texas two step'
00274                              )
00275 
00276         registry.registerStep( id='three'
00277                              , version='3'
00278                              , handler=THREE_FUNC
00279                              , dependencies=()
00280                              , title='Gimme three steps'
00281                              )
00282        
00283         steps = registry.sortSteps()
00284         self.assertEqual( len( steps ), 3 )
00285         one = steps.index( 'one' )
00286         two = steps.index( 'two' )
00287         three = steps.index( 'three' )
00288 
00289         self.failUnless( 0 <= three < one < two )
00290 

Definition at line 291 of file test_registry.py.

00291 
00292     def test_sortStep_complex( self ):
00293 
00294         registry = self._makeOne()
00295 
00296         registry.registerStep( id='one'
00297                              , version='1'
00298                              , handler=ONE_FUNC
00299                              , dependencies=( 'two', )
00300                              , title='One small step'
00301                              )
00302 
00303         registry.registerStep( id='two'
00304                              , version='2'
00305                              , handler=TWO_FUNC
00306                              , dependencies=( 'four', )
00307                              , title='Texas two step'
00308                              )
00309 
00310         registry.registerStep( id='three'
00311                              , version='3'
00312                              , handler=THREE_FUNC
00313                              , dependencies=( 'four', )
00314                              , title='Gimme three steps'
00315                              )
00316 
00317         registry.registerStep( id='four'
00318                              , version='4'
00319                              , handler=FOUR_FUNC
00320                              , dependencies=()
00321                              , title='Four step program'
00322                              )
00323 
00324         steps = registry.sortSteps()
00325         self.assertEqual( len( steps ), 4 )
00326         one = steps.index( 'one' )
00327         two = steps.index( 'two' )
00328         three = steps.index( 'three' )
00329         four = steps.index( 'four' )
00330 
00331         self.failUnless( 0 <= four < two < one )
00332         self.failUnless( 0 <= four < three )

Definition at line 333 of file test_registry.py.

00333 
00334     def test_sortStep_equivalence( self ):
00335 
00336         registry = self._makeOne()
00337 
00338         registry.registerStep( id='one'
00339                              , version='1'
00340                              , handler=ONE_FUNC
00341                              , dependencies=( 'two', 'three' )
00342                              , title='One small step'
00343                              )
00344 
00345         registry.registerStep( id='two'
00346                              , version='2'
00347                              , handler=TWO_FUNC
00348                              , dependencies=( 'four', )
00349                              , title='Texas two step'
00350                              )
00351 
00352         registry.registerStep( id='three'
00353                              , version='3'
00354                              , handler=THREE_FUNC
00355                              , dependencies=( 'four', )
00356                              , title='Gimme three steps'
00357                              )
00358 
00359         registry.registerStep( id='four'
00360                              , version='4'
00361                              , handler=FOUR_FUNC
00362                              , dependencies=()
00363                              , title='Four step program'
00364                              )
00365 
00366         steps = registry.sortSteps()
00367         self.assertEqual( len( steps ), 4 )
00368         one = steps.index( 'one' )
00369         two = steps.index( 'two' )
00370         three = steps.index( 'three' )
00371         four = steps.index( 'four' )
00372 
00373         self.failUnless( 0 <= four < two < one )
00374         self.failUnless( 0 <= four < three < one )

Definition at line 234 of file test_registry.py.

00234 
00235     def test_sortStep_simple( self ):
00236 
00237         registry = self._makeOne()
00238 
00239         registry.registerStep( id='one'
00240                              , version='1'
00241                              , handler=ONE_FUNC
00242                              , dependencies=( 'two', )
00243                              )
00244 
00245         registry.registerStep( id='two'
00246                              , version='2'
00247                              , handler=TWO_FUNC
00248                              , dependencies=()
00249                              )
00250 
00251         steps = registry.sortSteps()
00252         self.assertEqual( len( steps ), 2 )
00253         one = steps.index( 'one' )
00254         two = steps.index( 'two' )
00255 
00256         self.failUnless( 0 <= two < one )


Member Data Documentation

Definition at line 61 of file test_registry.py.


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