Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions
DCWorkflow.tests.test_exportimport.WorkflowDefinitionConfiguratorTests Class Reference
Inheritance diagram for DCWorkflow.tests.test_exportimport.WorkflowDefinitionConfiguratorTests:
Inheritance graph
[legend]
Collaboration diagram for DCWorkflow.tests.test_exportimport.WorkflowDefinitionConfiguratorTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_getWorkflowInfo_dcworkflow_defaults
def test_getWorkflowInfo_dcworkflow_permissions
def test_getWorkflowInfo_dcworkflow_variables
def test_getWorkflowInfo_dcworkflow_states
def test_getWorkflowInfo_dcworkflow_transitions
def test_getWorkflowInfo_dcworkflow_worklists
def test_getWorkflowInfo_dcworkflow_scripts
def test_generateXML_empty
def test_generateWorkflowXML_normal
def test_generateWorkflowXML_multiple
def test_parseWorkflowXML_empty
def test_parseWorkflowXML_normal_attribs
def test_parseWorkflowXML_normal_states
def test_parseWorkflowXML_normal_transitions
def test_parseWorkflowXML_normal_variables
def test_parseWorkflowXML_normal_worklists
def test_parseWorkflowXML_normal_permissions
def test_parseWorkflowXML_normal_scripts

Static Public Attributes

 layer = ExportImportZCMLLayer

Private Member Functions

def _getTargetClass

Detailed Description

Definition at line 192 of file test_exportimport.py.


Member Function Documentation

Definition at line 196 of file test_exportimport.py.

00196 
00197     def _getTargetClass( self ):
00198         from Products.DCWorkflow.exportimport \
00199                 import WorkflowDefinitionConfigurator
00200 
00201         return WorkflowDefinitionConfigurator

Definition at line 517 of file test_exportimport.py.

00517 
00518     def test_generateWorkflowXML_multiple( self ):
00519 
00520         WF_ID_1 = 'dc1'
00521         WF_TITLE_1 = 'Normal DCWorkflow #1'
00522         WF_DESCRIPTION_1 = 'Normal Number 1'
00523         WF_ID_2 = 'dc2'
00524         WF_TITLE_2 = 'Normal DCWorkflow #2'
00525         WF_DESCRIPTION_2 = 'Normal Numer 2'
00526         WF_INITIAL_STATE = 'closed'
00527 
00528         site = self._initSite()
00529 
00530         dcworkflow_1 = self._initDCWorkflow( WF_ID_1 )
00531         dcworkflow_1.title = WF_TITLE_1
00532         dcworkflow_1.description = WF_DESCRIPTION_1
00533         dcworkflow_1.initial_state = WF_INITIAL_STATE
00534         dcworkflow_1.permissions = _WF_PERMISSIONS
00535         self._initVariables( dcworkflow_1 )
00536         self._initStates( dcworkflow_1 )
00537         self._initTransitions( dcworkflow_1 )
00538         self._initWorklists( dcworkflow_1 )
00539         self._initScripts( dcworkflow_1 )
00540 
00541         dcworkflow_2 = self._initDCWorkflow( WF_ID_2 )
00542         dcworkflow_2.title = WF_TITLE_2
00543         dcworkflow_2.description = WF_DESCRIPTION_2
00544         dcworkflow_2.initial_state = WF_INITIAL_STATE
00545         dcworkflow_2.permissions = _WF_PERMISSIONS
00546         self._initVariables( dcworkflow_2 )
00547         self._initStates( dcworkflow_2 )
00548         self._initTransitions( dcworkflow_2 )
00549         self._initWorklists( dcworkflow_2 )
00550         self._initScripts( dcworkflow_2 )
00551 
00552         configurator = self._makeOne(dcworkflow_1).__of__(site)
00553 
00554         self._compareDOM( configurator.generateWorkflowXML()
00555                         , _NORMAL_WORKFLOW_EXPORT
00556                           % { 'workflow_id' : WF_ID_1
00557                             , 'title' : WF_TITLE_1
00558                             , 'description' : WF_DESCRIPTION_1
00559                             , 'initial_state' : WF_INITIAL_STATE
00560                             , 'workflow_filename' : WF_ID_1.replace(' ', '_')
00561                             } )
00562 
00563         configurator = self._makeOne(dcworkflow_2).__of__(site)
00564 
00565         self._compareDOM( configurator.generateWorkflowXML()
00566                         , _NORMAL_WORKFLOW_EXPORT
00567                           % { 'workflow_id' : WF_ID_2
00568                             , 'title' : WF_TITLE_2
00569                             , 'description' : WF_DESCRIPTION_2
00570                             , 'initial_state' : WF_INITIAL_STATE
00571                             , 'workflow_filename' : WF_ID_2.replace(' ', '_')
00572                             } )

Definition at line 487 of file test_exportimport.py.

00487 
00488     def test_generateWorkflowXML_normal( self ):
00489 
00490         WF_ID = 'normal'
00491         WF_TITLE = 'Normal DCWorkflow'
00492         WF_DESCRIPTION = 'Normal Workflow'
00493         WF_INITIAL_STATE = 'closed'
00494 
00495         site = self._initSite()
00496         dcworkflow = self._initDCWorkflow( WF_ID )
00497         dcworkflow.title = WF_TITLE
00498         dcworkflow.description = WF_DESCRIPTION
00499         dcworkflow.initial_state = WF_INITIAL_STATE
00500         dcworkflow.permissions = _WF_PERMISSIONS
00501         self._initVariables( dcworkflow )
00502         self._initStates( dcworkflow )
00503         self._initTransitions( dcworkflow )
00504         self._initWorklists( dcworkflow )
00505         self._initScripts( dcworkflow )
00506 
00507         configurator = self._makeOne(dcworkflow).__of__(site)
00508 
00509         self._compareDOM( configurator.generateWorkflowXML()
00510                         , _NORMAL_WORKFLOW_EXPORT
00511                           % { 'workflow_id' : WF_ID
00512                             , 'title' : WF_TITLE
00513                             , 'description' : WF_DESCRIPTION
00514                             , 'initial_state' : WF_INITIAL_STATE
00515                             , 'workflow_filename' : WF_ID.replace(' ', '_')
00516                             } )

Definition at line 465 of file test_exportimport.py.

00465 
00466     def test_generateXML_empty( self ):
00467 
00468         WF_ID = 'empty'
00469         WF_TITLE = 'Empty DCWorkflow'
00470         WF_DESCRIPTION = 'This is a empty workflow'
00471         WF_INITIAL_STATE = 'initial'
00472 
00473         site = self._initSite()
00474         dcworkflow = self._initDCWorkflow( WF_ID )
00475         dcworkflow.title = WF_TITLE
00476         dcworkflow.description = WF_DESCRIPTION
00477         dcworkflow.initial_state = WF_INITIAL_STATE
00478 
00479         configurator = self._makeOne(dcworkflow).__of__(site)
00480 
00481         self._compareDOM( configurator.generateWorkflowXML()
00482                         , _EMPTY_WORKFLOW_EXPORT % ( WF_ID
00483                                                    , WF_TITLE
00484                                                    , WF_DESCRIPTION
00485                                                    , WF_INITIAL_STATE
00486                                                    ) )

Definition at line 202 of file test_exportimport.py.

00202 
00203     def test_getWorkflowInfo_dcworkflow_defaults( self ):
00204 
00205         WF_ID = 'dcworkflow_defaults'
00206 
00207         site = self._initSite()
00208         dcworkflow = self._initDCWorkflow( WF_ID )
00209 
00210         configurator = self._makeOne(dcworkflow).__of__(site)
00211         info = configurator.getWorkflowInfo( WF_ID )
00212 
00213         self.assertEqual( info[ 'id' ], WF_ID )
00214         self.assertEqual( info[ 'meta_type' ], DCWorkflowDefinition.meta_type )
00215         self.assertEqual( info[ 'title' ], dcworkflow.title )
00216         self.assertEqual( info['description'], dcworkflow.description )
00217 
00218         self.assertEqual( info[ 'state_variable' ], dcworkflow.state_var )
00219 
00220         self.assertEqual( len( info[ 'permissions' ] ), 0 )
00221         self.assertEqual( len( info[ 'variable_info' ] ), 0 )
00222         self.assertEqual( len( info[ 'state_info' ] ), 0 )
00223         self.assertEqual( len( info[ 'transition_info' ] ), 0 )

Definition at line 224 of file test_exportimport.py.

00224 
00225     def test_getWorkflowInfo_dcworkflow_permissions( self ):
00226 
00227         WF_ID = 'dcworkflow_permissions'
00228 
00229         site = self._initSite()
00230         dcworkflow = self._initDCWorkflow( WF_ID )
00231         dcworkflow.permissions = _WF_PERMISSIONS
00232 
00233         configurator = self._makeOne(dcworkflow).__of__(site)
00234         info = configurator.getWorkflowInfo( WF_ID )
00235 
00236         permissions = info[ 'permissions' ]
00237         self.assertEqual( len( permissions ), len( _WF_PERMISSIONS ) )
00238 
00239         for permission in _WF_PERMISSIONS:
00240             self.failUnless( permission in permissions )

Definition at line 434 of file test_exportimport.py.

00434 
00435     def test_getWorkflowInfo_dcworkflow_scripts( self ):
00436 
00437         WF_ID = 'dcworkflow_scripts'
00438 
00439         site = self._initSite()
00440         dcworkflow = self._initDCWorkflow( WF_ID )
00441         self._initScripts( dcworkflow )
00442 
00443         configurator = self._makeOne(dcworkflow).__of__(site)
00444         info = configurator.getWorkflowInfo( WF_ID )
00445 
00446         script_info = info[ 'script_info' ]
00447         self.assertEqual( len( script_info ), len( _WF_SCRIPTS ) )
00448 
00449         ids = [ x[ 'id' ] for x in script_info ]
00450 
00451         for k in _WF_SCRIPTS.keys():
00452             self.failUnless( k in ids )
00453 
00454         for info in script_info:
00455 
00456             expected = _WF_SCRIPTS[ info[ 'id' ] ]
00457 
00458             self.assertEqual( info[ 'meta_type' ], expected[ 0 ] )
00459 
00460             if info[ 'meta_type' ] == PythonScript.meta_type:
00461                 self.assertEqual( info[ 'filename' ]
00462                                 , expected[ 2 ] % WF_ID )
00463             else:
00464                 self.assertEqual( info[ 'filename' ], expected[ 2 ] )

Definition at line 273 of file test_exportimport.py.

00273 
00274     def test_getWorkflowInfo_dcworkflow_states( self ):
00275 
00276         WF_ID = 'dcworkflow_states'
00277         WF_INITIAL_STATE = 'closed'
00278 
00279         site = self._initSite()
00280         dcworkflow = self._initDCWorkflow( WF_ID )
00281         dcworkflow.initial_state = WF_INITIAL_STATE
00282         self._initStates( dcworkflow )
00283 
00284         configurator = self._makeOne(dcworkflow).__of__(site)
00285         info = configurator.getWorkflowInfo( WF_ID )
00286 
00287         self.assertEqual( info[ 'state_variable' ], dcworkflow.state_var )
00288         self.assertEqual( info[ 'initial_state' ], dcworkflow.initial_state )
00289 
00290         state_info = info[ 'state_info' ]
00291         self.assertEqual( len( state_info ), len( _WF_STATES ) )
00292 
00293         ids = [ x[ 'id' ] for x in state_info ]
00294 
00295         for k in _WF_STATES.keys():
00296             self.failUnless( k in ids )
00297 
00298         for info in state_info:
00299 
00300             expected = _WF_STATES[ info[ 'id' ] ]
00301 
00302             self.assertEqual( info[ 'title' ], expected[ 0 ] )
00303             self.assertEqual( info[ 'description' ], expected[ 1 ] )
00304             self.assertEqual( info[ 'transitions' ], expected[ 2 ] )
00305 
00306             permissions = info[ 'permissions' ]
00307 
00308             self.assertEqual( len( permissions ), len( expected[ 3 ] ) )
00309 
00310             for ep_id, ep_roles in expected[ 3 ].items():
00311 
00312                 fp = [ x for x in permissions if x[ 'name' ] == ep_id ][ 0 ]
00313 
00314                 self.assertEqual( fp[ 'acquired' ]
00315                                 , not isinstance( ep_roles, tuple ) )
00316 
00317                 self.assertEqual( len( fp[ 'roles' ] ), len( ep_roles ) )
00318 
00319                 for ep_role in ep_roles:
00320                     self.failUnless( ep_role in fp[ 'roles' ] )
00321 
00322             groups = info[ 'groups' ]
00323             self.assertEqual( len( groups ), len( expected[ 4 ] ) )
00324 
00325             for i in range( len( groups ) ):
00326                 self.assertEqual( groups[ i ], expected[ 4 ][ i ] )
00327 
00328             variables = info[ 'variables' ]
00329             self.assertEqual( len( variables ), len( expected[ 5 ] ) )
00330 
00331             for v_info in variables:
00332 
00333                 name, type, value = ( v_info[ 'name' ]
00334                                     , v_info[ 'type' ], v_info[ 'value' ] )
00335 
00336                 self.assertEqual( value, expected[ 5 ][ name ] )
00337 
00338                 if isinstance( value, bool ):
00339                     self.assertEqual( type, 'bool' )
00340                 elif isinstance( value, int ):
00341                     self.assertEqual( type, 'int' )
00342                 elif isinstance( value, float ):
00343                     self.assertEqual( type, 'float' )
00344                 elif isinstance( value, basestring ):
00345                     self.assertEqual( type, 'string' )

Definition at line 346 of file test_exportimport.py.

00346 
00347     def test_getWorkflowInfo_dcworkflow_transitions( self ):
00348 
00349         from Products.DCWorkflow.exportimport import TRIGGER_TYPES
00350 
00351         WF_ID = 'dcworkflow_transitions'
00352 
00353         site = self._initSite()
00354         dcworkflow = self._initDCWorkflow( WF_ID )
00355         self._initTransitions( dcworkflow )
00356 
00357         configurator = self._makeOne(dcworkflow).__of__(site)
00358         info = configurator.getWorkflowInfo( WF_ID )
00359 
00360         transition_info = info[ 'transition_info' ]
00361         self.assertEqual( len( transition_info ), len( _WF_TRANSITIONS ) )
00362 
00363         ids = [ x[ 'id' ] for x in transition_info ]
00364 
00365         for k in _WF_TRANSITIONS.keys():
00366             self.failUnless( k in ids )
00367 
00368         for info in transition_info:
00369 
00370             expected = _WF_TRANSITIONS[ info[ 'id' ] ]
00371 
00372             self.assertEqual( info[ 'title' ], expected[ 0 ] )
00373             self.assertEqual( info[ 'description' ], expected[ 1 ] )
00374             self.assertEqual( info[ 'new_state_id' ], expected[ 2 ] )
00375             self.assertEqual( info[ 'trigger_type' ]
00376                             , TRIGGER_TYPES[ expected[ 3 ] ] )
00377             self.assertEqual( info[ 'script_name' ], expected[ 4 ] )
00378             self.assertEqual( info[ 'after_script_name' ], expected[ 5 ] )
00379             self.assertEqual( info[ 'actbox_name' ], expected[ 6 ] )
00380             self.assertEqual( info[ 'actbox_url' ], expected[ 7 ] )
00381             self.assertEqual( info[ 'actbox_category' ], expected[ 8 ] )
00382 
00383             variables = info[ 'variables' ]
00384             self.assertEqual( len( variables ), len( expected[ 9 ] ) )
00385 
00386             for v_info in variables:
00387                 self.assertEqual( v_info[ 'expr' ]
00388                                 , expected[ 9 ][ v_info[ 'name' ] ] )
00389 
00390             self._assertGuard( info, *expected[ -4: ] )

Definition at line 241 of file test_exportimport.py.

00241 
00242     def test_getWorkflowInfo_dcworkflow_variables( self ):
00243 
00244         WF_ID = 'dcworkflow_variables'
00245 
00246         site = self._initSite()
00247         dcworkflow = self._initDCWorkflow( WF_ID )
00248         self._initVariables( dcworkflow )
00249 
00250         configurator = self._makeOne(dcworkflow).__of__(site)
00251         info = configurator.getWorkflowInfo( WF_ID )
00252 
00253         variable_info = info[ 'variable_info' ]
00254         self.assertEqual( len( variable_info ), len( _WF_VARIABLES ) )
00255 
00256         ids = [ x[ 'id' ] for x in variable_info ]
00257 
00258         for k in _WF_VARIABLES.keys():
00259             self.failUnless( k in ids )
00260 
00261         for info in variable_info:
00262 
00263             expected = _WF_VARIABLES[ info[ 'id' ] ]
00264 
00265             self.assertEqual( info[ 'description' ], expected[ 0 ] )
00266             self.assertEqual( info[ 'default_value' ], expected[ 1 ] )
00267             self.assertEqual( info[ 'default_expr' ], expected[ 2 ] )
00268             self.assertEqual( info[ 'for_catalog' ], expected[ 3 ] )
00269             self.assertEqual( info[ 'for_status' ], expected[ 4 ] )
00270             self.assertEqual( info[ 'update_always' ], expected[ 5 ] )
00271 
00272             self._assertGuard( info, *expected[ -4: ] )

Definition at line 391 of file test_exportimport.py.

00391 
00392     def test_getWorkflowInfo_dcworkflow_worklists( self ):
00393 
00394         WF_ID = 'dcworkflow_worklists'
00395 
00396         site = self._initSite()
00397         dcworkflow = self._initDCWorkflow( WF_ID )
00398         self._initWorklists( dcworkflow )
00399 
00400         configurator = self._makeOne(dcworkflow).__of__(site)
00401         info = configurator.getWorkflowInfo( WF_ID )
00402 
00403         worklist_info = info[ 'worklist_info' ]
00404         self.assertEqual( len( worklist_info ), len( _WF_WORKLISTS ) )
00405 
00406         ids = [ x[ 'id' ] for x in worklist_info ]
00407 
00408         for k in _WF_WORKLISTS.keys():
00409             self.failUnless( k in ids )
00410 
00411         for info in worklist_info:
00412 
00413             expected = _WF_WORKLISTS[ info[ 'id' ] ]
00414 
00415             self.assertEqual( info[ 'title' ], expected[ 0 ] )
00416             self.assertEqual( info[ 'description' ], expected[ 1 ] )
00417             self.assertEqual( info[ 'actbox_name' ], expected[ 3 ] )
00418             self.assertEqual( info[ 'actbox_url' ], expected[ 4 ] )
00419             self.assertEqual( info[ 'actbox_category' ], expected[ 5 ] )
00420 
00421             var_match = info[ 'var_match' ]
00422             self.assertEqual( len( var_match ), len( expected[ 2 ] ) )
00423 
00424             for var_id, values_txt in var_match:
00425 
00426                 values = [ x.strip() for x in values_txt.split( ';' ) ]
00427                 e_values = expected[ 2 ][ var_id ]
00428                 self.assertEqual( len( values ), len( e_values ) )
00429 
00430                 for e_value in e_values:
00431                     self.failUnless( e_value in values )
00432 
00433             self._assertGuard( info, *expected[ -4: ] )

Definition at line 573 of file test_exportimport.py.

00573 
00574     def test_parseWorkflowXML_empty( self ):
00575 
00576         WF_ID = 'empty'
00577         WF_TITLE = 'Empty DCWorkflow'
00578         WF_DESCRIPTION = 'This is an empty workflow'
00579         WF_INITIAL_STATE = 'initial'
00580 
00581         site = self._initSite()
00582 
00583         configurator = self._makeOne( site ).__of__( site )
00584 
00585         ( workflow_id
00586         , title
00587         , state_variable
00588         , initial_state
00589         , states
00590         , transitions
00591         , variables
00592         , worklists
00593         , permissions
00594         , scripts
00595         , description
00596         ) = configurator.parseWorkflowXML( _EMPTY_WORKFLOW_EXPORT
00597                                          % ( WF_ID
00598                                            , WF_TITLE
00599                                            , WF_DESCRIPTION
00600                                            , WF_INITIAL_STATE
00601                                            ) )
00602 
00603         self.assertEqual(description, WF_DESCRIPTION)
00604         self.assertEqual( len( states ), 0 )
00605         self.assertEqual( len( transitions ), 0 )
00606         self.assertEqual( len( variables ), 0 )
00607         self.assertEqual( len( worklists ), 0 )
00608         self.assertEqual( len( permissions ), 0 )
00609         self.assertEqual( len( scripts ), 0 )

Definition at line 610 of file test_exportimport.py.

00610 
00611     def test_parseWorkflowXML_normal_attribs( self ):
00612 
00613         WF_ID = 'normal'
00614         WF_TITLE = 'Normal DCWorkflow'
00615         WF_DESCRIPTION = 'This is a normal DCWorkflow'
00616         WF_INITIAL_STATE = 'closed'
00617 
00618         site = self._initSite()
00619 
00620         configurator = self._makeOne( site ).__of__( site )
00621 
00622         ( workflow_id
00623         , title
00624         , state_variable
00625         , initial_state
00626         , states
00627         , transitions
00628         , variables
00629         , worklists
00630         , permissions
00631         , scripts
00632         , description
00633         ) = configurator.parseWorkflowXML(
00634                           _NORMAL_WORKFLOW_EXPORT
00635                           % { 'workflow_id' : WF_ID
00636                             , 'title' : WF_TITLE
00637                             , 'description' : WF_DESCRIPTION
00638                             , 'initial_state' : WF_INITIAL_STATE
00639                             , 'workflow_filename' : WF_ID.replace(' ', '_')
00640                             } )
00641 
00642         self.assertEqual( workflow_id, WF_ID )
00643         self.assertEqual( title, WF_TITLE )
00644         self.assertEqual( description, WF_DESCRIPTION )
00645         self.assertEqual( state_variable, 'state' )
00646         self.assertEqual( initial_state, WF_INITIAL_STATE )

Definition at line 921 of file test_exportimport.py.

00921 
00922     def test_parseWorkflowXML_normal_permissions( self ):
00923 
00924         WF_ID = 'normal'
00925         WF_TITLE = 'Normal DCWorkflow'
00926         WF_DESCRIPTION = 'Normal workflow'
00927         WF_INITIAL_STATE = 'closed'
00928 
00929         site = self._initSite()
00930 
00931         configurator = self._makeOne( site ).__of__( site )
00932 
00933         ( workflow_id
00934         , title
00935         , state_variable
00936         , initial_state
00937         , states
00938         , transitions
00939         , variables
00940         , worklists
00941         , permissions
00942         , scripts
00943         , description
00944         ) = configurator.parseWorkflowXML(
00945                           _NORMAL_WORKFLOW_EXPORT
00946                           % { 'workflow_id' : WF_ID
00947                             , 'title' : WF_TITLE
00948                             , 'description' : WF_DESCRIPTION
00949                             , 'initial_state' : WF_INITIAL_STATE
00950                             , 'workflow_filename' : WF_ID.replace(' ', '_')
00951                             } )
00952 
00953         self.assertEqual( len( permissions ), len( _WF_PERMISSIONS ) )
00954 
00955         for permission in permissions:
00956 
00957             self.failUnless( permission in _WF_PERMISSIONS )

Definition at line 958 of file test_exportimport.py.

00958 
00959     def test_parseWorkflowXML_normal_scripts( self ):
00960 
00961         WF_ID = 'normal'
00962         WF_TITLE = 'Normal DCWorkflow'
00963         WF_DESCRIPTION = 'Normal workflow'
00964         WF_INITIAL_STATE = 'closed'
00965 
00966         site = self._initSite()
00967 
00968         configurator = self._makeOne( site ).__of__( site )
00969 
00970         ( workflow_id
00971         , title
00972         , state_variable
00973         , initial_state
00974         , states
00975         , transitions
00976         , variables
00977         , worklists
00978         , permissions
00979         , scripts
00980         , description
00981         ) = configurator.parseWorkflowXML(
00982                           _NORMAL_WORKFLOW_EXPORT
00983                           % { 'workflow_id' : WF_ID
00984                             , 'title' : WF_TITLE
00985                             , 'description': WF_DESCRIPTION
00986                             , 'initial_state' : WF_INITIAL_STATE
00987                             , 'workflow_filename' : WF_ID.replace(' ', '_')
00988                             } )
00989 
00990         self.assertEqual( len( scripts ), len( _WF_SCRIPTS ) )
00991 
00992         for script in scripts:
00993 
00994             script_id = script[ 'script_id' ]
00995             self.failUnless( script_id in _WF_SCRIPTS )
00996 
00997             expected = _WF_SCRIPTS[ script_id ]
00998 
00999             self.assertEqual( script[ 'meta_type' ], expected[ 0 ] )
01000 
01001             # Body is not kept as part of the workflow XML
01002 
01003             if script[ 'meta_type' ] == PythonScript.meta_type:
01004                 self.assertEqual( script[ 'filename' ]
01005                                 , expected[ 2 ] % workflow_id )
01006             else:
01007                 self.assertEqual( script[ 'filename' ], expected[ 2 ] )
01008 

Definition at line 647 of file test_exportimport.py.

00647 
00648     def test_parseWorkflowXML_normal_states( self ):
00649 
00650         WF_ID = 'normal'
00651         WF_TITLE = 'Normal DCWorkflow'
00652         WF_DESCRIPTION = 'Normal workflow'
00653         WF_INITIAL_STATE = 'closed'
00654 
00655         site = self._initSite()
00656 
00657         configurator = self._makeOne( site ).__of__( site )
00658 
00659         ( workflow_id
00660         , title
00661         , state_variable
00662         , initial_state
00663         , states
00664         , transitions
00665         , variables
00666         , worklists
00667         , permissions
00668         , scripts
00669         , description
00670         ) = configurator.parseWorkflowXML(
00671                           _NORMAL_WORKFLOW_EXPORT
00672                           % { 'workflow_id' : WF_ID
00673                             , 'title' : WF_TITLE
00674                             , 'description' : WF_DESCRIPTION
00675                             , 'initial_state' : WF_INITIAL_STATE
00676                             , 'workflow_filename' : WF_ID.replace(' ', '_')
00677                             } )
00678 
00679         self.assertEqual( len( states ), len( _WF_STATES ) )
00680 
00681         for state in states:
00682 
00683             state_id = state[ 'state_id' ]
00684             self.failUnless( state_id in _WF_STATES )
00685 
00686             expected = _WF_STATES[ state_id ]
00687 
00688             self.assertEqual( state[ 'title' ], expected[ 0 ] )
00689 
00690             description = ''.join( state[ 'description' ] )
00691             self.failUnless( expected[ 1 ] in description )
00692 
00693             self.assertEqual( tuple( state[ 'transitions' ] ), expected[ 2 ] )
00694             self.assertEqual( state[ 'permissions' ], expected[ 3 ] )
00695             self.assertEqual( tuple( state[ 'groups' ] )
00696                             , tuple( expected[ 4 ] ) )
00697 
00698             for k, v_info in state[ 'variables' ].items():
00699 
00700                 exp_value = expected[ 5 ][ k ]
00701                 self.assertEqual( v_info[ 'value' ], str( exp_value ) )
00702 
00703                 if isinstance( exp_value, bool ):
00704                     self.assertEqual( v_info[ 'type' ], 'bool' )
00705                 elif isinstance( exp_value, int ):
00706                     self.assertEqual( v_info[ 'type' ], 'int' )
00707                 elif isinstance( exp_value, float ):
00708                     self.assertEqual( v_info[ 'type' ], 'float' )
00709                 elif isinstance( exp_value, basestring ):
00710                     self.assertEqual( v_info[ 'type' ], 'string' )

Definition at line 711 of file test_exportimport.py.

00711 
00712     def test_parseWorkflowXML_normal_transitions( self ):
00713 
00714         from Products.DCWorkflow.exportimport import TRIGGER_TYPES
00715 
00716         WF_ID = 'normal'
00717         WF_TITLE = 'Normal DCWorkflow'
00718         WF_DESCRIPTION = 'Normal workflow'
00719         WF_INITIAL_STATE = 'closed'
00720 
00721         site = self._initSite()
00722 
00723         configurator = self._makeOne( site ).__of__( site )
00724 
00725         ( workflow_id
00726         , title
00727         , state_variable
00728         , initial_state
00729         , states
00730         , transitions
00731         , variables
00732         , worklists
00733         , permissions
00734         , scripts
00735         , description 
00736         ) = configurator.parseWorkflowXML(
00737                           _NORMAL_WORKFLOW_EXPORT
00738                           % { 'workflow_id' : WF_ID
00739                             , 'title' : WF_TITLE
00740                             , 'description' : WF_DESCRIPTION
00741                             , 'initial_state' : WF_INITIAL_STATE
00742                             , 'workflow_filename' : WF_ID.replace(' ', '_')
00743                             } )
00744 
00745         self.assertEqual( len( transitions ), len( _WF_TRANSITIONS ) )
00746 
00747         for transition in transitions:
00748 
00749             transition_id = transition[ 'transition_id' ]
00750             self.failUnless( transition_id in _WF_TRANSITIONS )
00751 
00752             expected = _WF_TRANSITIONS[ transition_id ]
00753 
00754             self.assertEqual( transition[ 'title' ], expected[ 0 ] )
00755 
00756             description = ''.join( transition[ 'description' ] )
00757             self.failUnless( expected[ 1 ] in description )
00758 
00759             self.assertEqual( transition[ 'new_state' ], expected[ 2 ] )
00760             self.assertEqual( transition[ 'trigger' ]
00761                             , TRIGGER_TYPES[ expected[ 3 ] ] )
00762             self.assertEqual( transition[ 'before_script' ], expected[ 4 ] )
00763             self.assertEqual( transition[ 'after_script' ]
00764                             , expected[ 5 ] )
00765 
00766             action = transition[ 'action' ]
00767             self.assertEqual( action.get( 'name', '' ), expected[ 6 ] )
00768             self.assertEqual( action.get( 'url', '' ), expected[ 7 ] )
00769             self.assertEqual( action.get( 'category', '' ), expected[ 8 ] )
00770 
00771             self.assertEqual( transition[ 'variables' ], expected[ 9 ] )
00772 
00773             guard = transition[ 'guard' ]
00774             self.assertEqual( tuple( guard.get( 'permissions', () ) )
00775                             , expected[ 10 ] )
00776             self.assertEqual( tuple( guard.get( 'roles', () ) )
00777                             , expected[ 11 ] )
00778             self.assertEqual( tuple( guard.get( 'groups', () ) )
00779                             , expected[ 12 ] )
00780             self.assertEqual( guard.get( 'expression', '' ), expected[ 13 ] )

Definition at line 781 of file test_exportimport.py.

00781 
00782     def test_parseWorkflowXML_normal_variables( self ):
00783 
00784         WF_ID = 'normal'
00785         WF_TITLE = 'Normal DCWorkflow'
00786         WF_DESCRIPTION = 'Normal workflow'
00787         WF_INITIAL_STATE = 'closed'
00788 
00789         site = self._initSite()
00790 
00791         configurator = self._makeOne( site ).__of__( site )
00792 
00793         ( workflow_id
00794         , title
00795         , state_variable
00796         , initial_state
00797         , states
00798         , transitions
00799         , variables
00800         , worklists
00801         , permissions
00802         , scripts
00803         , description
00804         ) = configurator.parseWorkflowXML(
00805                           _NORMAL_WORKFLOW_EXPORT
00806                           % { 'workflow_id' : WF_ID
00807                             , 'title' : WF_TITLE
00808                             , 'description' : WF_DESCRIPTION
00809                             , 'initial_state' : WF_INITIAL_STATE
00810                             , 'workflow_filename' : WF_ID.replace(' ', '_')
00811                             } )
00812 
00813         self.assertEqual( len( variables ), len( _WF_VARIABLES ) )
00814 
00815         for variable in variables:
00816 
00817             variable_id = variable[ 'variable_id' ]
00818             self.failUnless( variable_id in _WF_VARIABLES )
00819 
00820             expected = _WF_VARIABLES[ variable_id ]
00821 
00822             description = ''.join( variable[ 'description' ] )
00823             self.failUnless( expected[ 0 ] in description )
00824 
00825             default = variable[ 'default' ]
00826             self.assertEqual( default[ 'value' ], expected[ 1 ] )
00827 
00828             exp_type = 'n/a'
00829 
00830             if expected[ 1 ]:
00831                 exp_value = expected[ 1 ]
00832 
00833                 if isinstance( exp_value, bool ):
00834                     exp_type = 'bool'
00835                 elif isinstance( exp_value, int ):
00836                     exp_type = 'int'
00837                 elif isinstance( exp_value, float ):
00838                     exp_type = 'float'
00839                 elif isinstance( exp_value, basestring ):
00840                     exp_type = 'string'
00841                 else:
00842                     exp_type = 'XXX'
00843 
00844             self.assertEqual( default[ 'type' ], exp_type )
00845             self.assertEqual( default[ 'expression' ], expected[ 2 ] )
00846 
00847             self.assertEqual( variable[ 'for_catalog' ], expected[ 3 ] )
00848             self.assertEqual( variable[ 'for_status' ], expected[ 4 ] )
00849             self.assertEqual( variable[ 'update_always' ], expected[ 5 ] )
00850 
00851             guard = variable[ 'guard' ]
00852             self.assertEqual( tuple( guard.get( 'permissions', () ) )
00853                             , expected[ 6 ] )
00854             self.assertEqual( tuple( guard.get( 'roles', () ) )
00855                             , expected[ 7 ] )
00856             self.assertEqual( tuple( guard.get( 'groups', () ) )
00857                             , expected[ 8 ] )
00858             self.assertEqual( guard.get( 'expression', '' ), expected[ 9 ] )

Definition at line 859 of file test_exportimport.py.

00859 
00860     def test_parseWorkflowXML_normal_worklists( self ):
00861 
00862         WF_ID = 'normal'
00863         WF_TITLE = 'Normal DCWorkflow'
00864         WF_DESCRIPTION = 'Normal workflow'
00865         WF_INITIAL_STATE = 'closed'
00866 
00867         site = self._initSite()
00868 
00869         configurator = self._makeOne( site ).__of__( site )
00870 
00871         ( workflow_id
00872         , title
00873         , state_variable
00874         , initial_state
00875         , states
00876         , transitions
00877         , variables
00878         , worklists
00879         , permissions
00880         , scripts
00881         , description
00882         ) = configurator.parseWorkflowXML(
00883                           _NORMAL_WORKFLOW_EXPORT
00884                           % { 'workflow_id' : WF_ID
00885                             , 'title' : WF_TITLE
00886                             , 'description' : WF_DESCRIPTION
00887                             , 'initial_state' : WF_INITIAL_STATE
00888                             , 'workflow_filename' : WF_ID.replace(' ', '_')
00889                             } )
00890 
00891         self.assertEqual( len( worklists ), len( _WF_WORKLISTS ) )
00892 
00893         for worklist in worklists:
00894 
00895             worklist_id = worklist[ 'worklist_id' ]
00896             self.failUnless( worklist_id in _WF_WORKLISTS )
00897 
00898             expected = _WF_WORKLISTS[ worklist_id ]
00899 
00900             self.assertEqual( worklist[ 'title' ], expected[ 0 ] )
00901 
00902             description = ''.join( worklist[ 'description' ] )
00903             self.failUnless( expected[ 1 ] in description )
00904 
00905             self.assertEqual( tuple( worklist[ 'match' ] )
00906                             , tuple( expected[ 2 ] ) )
00907 
00908             action = worklist[ 'action' ]
00909             self.assertEqual( action.get( 'name', '' ), expected[ 3 ] )
00910             self.assertEqual( action.get( 'url', '' ), expected[ 4 ] )
00911             self.assertEqual( action.get( 'category', '' ), expected[ 5 ] )
00912 
00913             guard = worklist[ 'guard' ]
00914             self.assertEqual( tuple( guard.get( 'permissions', () ) )
00915                             , expected[ 6 ] )
00916             self.assertEqual( tuple( guard.get( 'roles', () ) )
00917                             , expected[ 7 ] )
00918             self.assertEqual( tuple( guard.get( 'groups', () ) )
00919                             , expected[ 8 ] )
00920             self.assertEqual( guard.get( 'expression', '' ), expected[ 9 ] )


Member Data Documentation

Definition at line 194 of file test_exportimport.py.


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