====================================
Tests the migration tool's utilities
====================================

Ed Crewe, ILRT (University of Bristol) 
Feb 2009

There are curently three utilities ...

1. generic setup step runner
2. products quick installer runner
3. attribute pickler  

however the first two are just wrapper methods so is is only 
the attribute pickler that need testing ... 

Attribute pickler
-----------------

    >>> from ilrt.migrationtool.browser.utils import pickleAttributes

Make ourselves a manager so we can do some doc creation

    >>> self.setRoles(['Manager'])

Add a document and set a test attribute on it

    >>> id = portal.invokeFactory(id='doc', type_name='Document')
    >>> document = portal[id]
    >>> setattr(document,'gherkin','Cucumbers and vinegar')

Check it has the attribute

    >>> getattr(document,'gherkin',None)
    'Cucumbers and vinegar'

Now we will pickle our attribute with the utility

    >>> out = []
    >>> pickleAttributes(portal,out,['gherkin',],'/' + id,'save')
    >>> out[0].startswith('You have saved your attributes') 
    True
    
We shall now delete and replace the document as could happen in order to
reinstantiate an object whose class was altered by a migration

    >>> portal._delObject(id)
    >>> getattr(portal,id,None) == None    
    True

Now lets put it back

    >>> id = portal.invokeFactory(id='doc', type_name='Document')
    >>> document = portal[id]
    >>> setattr(document,'gherkin','')

Finally we will run our attibute pickler again and see if it restores the 
attributes data ...

    >>> pickleAttributes(portal,out,['gherkin',],'/' + id,'load')
    >>> document.gherkin
    'Cucumbers and vinegar'
