ATAudio Migration
=================

Start by adding a new ATAudio instance to the site.

  >>> import Globals
  >>> import os
  >>> import transaction
  
  >>> self.setRoles(['Manager', 'Member'])
  
  >>> id = folder.invokeFactory('ATAudio', 'test-audio')
  >>> testaudio = folder[id]
  >>> maindir = Globals.package_home({'__name__': 'p4a.audio.tests'})
  >>> samplesdir = os.path.join(maindir, 'samples')
  >>> f = open(os.path.join(samplesdir, 'test-full.mp3'))
  >>> testaudio.setFile(f)
  >>> f.close()
  >>> testaudio.processForm()
  >>> transaction.commit()

Make sure the instance was created properly and we got some valid
metadata.

  >>> items = folder.getFolderContents(contentFilter={'portal_type': 'ATAudio'})
  >>> len(items)
  1
  
  >>> testaudio = items[0].getObject()
  >>> testaudio.Title()
  'Test of the Emercy Broadcast System'

Now we invoke the migration mechanism via the confliget view (for
the sake of integration).  By default the configlet should run in *dry
run* mode so all changes will be rolled back.

  >>> view = portal.restrictedTraverse('@@migrate-ataudio-configlet.html')
  >>> view.dry_run
  True

The following tests are no longer run as it appears that ExternalStorage
cannot roll back the deletion of a file on the filesystem.

  >>> # view.migrate()
  'Successfully migrated 1 object(s), which were rolled back due to running in "dry run" mode'

We try the migration again, this time not running in dry mode.

  >>> view.request.form['dry_run'] = False
  >>> view.dry_run
  False
  >>> view.migrate()
  'Successfully migrated 1 object(s)'
  
Now that the objects have been migrated, lets check one out to ensure
all metadata was brought over properly.

  >>> from p4a.audio import interfaces

  >>> obj = folder['test-audio']
  >>> obj.portal_type
  'File'

  >>> audio = interfaces.IAudio(obj)
  >>> audio.title
  u'Test of the Emercy Broadcast System'
  >>> audio.length
  3
