========================================
Tests for the workflow migration utility
========================================

Ed Crewe, ILRT (University of Bristol) 
January 2009

Unit tests for the workflow tool
--------------------------------

(Depends on default plone portal_workflow being set up)

Lets get the workflow migration tool

    >>> request = getattr(self,'REQUEST',{}) 
    >>> from ilrt.migrationtool.browser.workflowtool import WorkflowMigrationView
    >>> wfmt = WorkflowMigrationView(portal,request)

Lets check the tool is there and listing workflows ...

    >>> wfs = wfmt.listWorkflows()
    >>> wf_item = {'id':'plone_workflow','title':'Community Workflow'}
    >>> wf_item in wfs
    True

Now we will set up a workflow migration

    >>> wfmt.setWorkflowMigration('simple_publication_workflow','intranet_workflow')
    
Check that this has been set

    >>> wfs = wfmt.getWorkflowMigration()
    >>> for wf in wfs:
    ...     wf.title
    'Simple Publication Workflow'
    'Intranet/Extranet Workflow'

Confirm that the state map method works

    >>> transdict = wfmt.getTransitionStateMap('simple_publication_workflow')
    >>> transdict['published']
    'publish'    
    >>> transdict['private']
    'reject'    
    >>> transdict['pending']
    'submit'    

Test the transfer on the portal
-------------------------------

Ok now we need to set the mapping of states for this transfer

   >>> wfmt._mapping = {'private':'private','pending':'pending',
   ...                  'published':'internally_published'}

Set up the portal with simple publication workflow

Add a document

Publish it

Now change to intranet workflow

Check to see that the documents state has become default private

Run the transfer

Confirm we have moved the objects state to what we wanted in our mapping
ie. published content should become internally published.
