Back to index

plone3  3.1.7
testMigrationTool.py
Go to the documentation of this file.
00001 #
00002 # MigrationTool tests
00003 #
00004 
00005 from Products.CMFPlone.tests import PloneTestCase
00006 from Products.CMFPlone.interfaces import IMigrationTool
00007 from Products.CMFCore.utils import getToolByName
00008 
00009 class TestMigrationTool(PloneTestCase.PloneTestCase):
00010 
00011     def afterSetUp(self):
00012         self.migration = getToolByName(self, "portal_migration")
00013 
00014     def testMigrationFinished(self):
00015         self.assertEqual(self.migration.getInstanceVersion(),
00016                          self.migration.getFileSystemVersion(),
00017                          'Migration failed')
00018 
00019     def testMigrationNeedsUpgrading(self):
00020         self.failIf(self.migration.needUpgrading(),
00021                     'Migration needs upgrading')
00022 
00023     def testMigrationNeedsUpdateRole(self):
00024         self.failIf(self.migration.needUpdateRole(),
00025                     'Migration needs role update')
00026 
00027     def testMigrationNeedsRecatalog(self):
00028         self.failIf(self.migration.needRecatalog(),
00029                     'Migration needs recataloging')
00030 
00031     def testForceMigrationFromUnsupportedVersion(self):
00032         version = '2.0.5'
00033         while version is not None:
00034             version, msg = self.migration._upgrade(version)
00035         expect = 'Migration stopped at version 2.0.5.'
00036         self.assertEqual(msg[0], expect)
00037 
00038     def testForceMigration(self):
00039         self.setRoles(['Manager'])
00040         # Make sure we don't embarrass ourselves again...
00041         version = '2.1'
00042         while version is not None:
00043             version, msg = self.migration._upgrade(version)
00044         expect = 'Migration completed at version %s.' % \
00045                  self.migration.getFileSystemVersion()
00046         self.assertEqual(msg[0], expect)
00047 
00048 
00049 def test_suite():
00050     from unittest import TestSuite, makeSuite
00051     suite = TestSuite()
00052     suite.addTest(makeSuite(TestMigrationTool))
00053     return suite