Back to index

plone3  3.1.7
testSetup.py
Go to the documentation of this file.
00001 #
00002 # Setup tests
00003 #
00004 
00005 import unittest
00006 
00007 from Testing import ZopeTestCase
00008 from Products.CMFTestCase import CMFTestCase
00009 
00010 CMFTestCase.installProduct('CMFQuickInstallerTool')
00011 CMFTestCase.setupCMFSite()
00012 
00013 from Products.CMFQuickInstallerTool.InstalledProduct import InstalledProduct
00014 
00015 
00016 class TestQuickInstaller(CMFTestCase.CMFTestCase):
00017 
00018     def afterSetUp(self):
00019         self.setRoles(['Manager'])
00020         self.addProduct('CMFQuickInstallerTool')
00021         self.qi = getattr(self.portal, 'portal_quickinstaller', None)
00022 
00023     def testTool(self):
00024         self.failUnless('portal_quickinstaller' in self.portal.objectIds())
00025 
00026     def testIsNotInstalled(self):
00027         self.failIf(self.qi.isProductInstalled('CMFQuickInstallerTool'))
00028 
00029     def testIsNotListedAsInstallable(self):
00030         prods = self.qi.listInstallableProducts()
00031         prods = [x['id'] for x in prods]
00032         self.failIf('CMFQuickInstallerTool' in prods)
00033 
00034     def testIsNotListedAsInstalled(self):
00035         prods = self.qi.listInstalledProducts()
00036         prods = [x['id'] for x in prods]
00037         self.failIf('CMFQuickInstallerTool' in prods)
00038 
00039 
00040 class TestInstalledProduct(CMFTestCase.CMFTestCase):
00041 
00042     def afterSetUp(self):
00043         self.setRoles(['Manager'])
00044         self.addProduct('CMFQuickInstallerTool')
00045         self.qi = getattr(self.portal, 'portal_quickinstaller', None)
00046 
00047     def testSlotsMigration(self):
00048         # leftslots and rightslots have been class variables ones. Make sure
00049         # using old instances without these properties doesn't break.
00050 
00051         # New instances should have the properties
00052         new = InstalledProduct('new')
00053         self.failUnless(hasattr(new, 'leftslots'))
00054         self.failUnless(hasattr(new, 'rightslots'))
00055 
00056         # Now emulate an old instance
00057         old = InstalledProduct('old')
00058         del(old.leftslots)
00059         del(old.rightslots)
00060 
00061         # Make sure calling the API will give you no error but silently
00062         # add the property
00063         left = old.getLeftSlots()
00064         self.failUnless(left == [])
00065         self.failUnless(old.leftslots == [])
00066 
00067         right = old.getRightSlots()
00068         self.failUnless(right == [])
00069         self.failUnless(old.rightslots == [])
00070 
00071         slots = old.getSlots()
00072         self.failUnless(slots == [])
00073 
00074 
00075 def test_suite():
00076     suite = unittest.TestSuite()
00077     suite.addTest(unittest.makeSuite(TestQuickInstaller))
00078     suite.addTest(unittest.makeSuite(TestInstalledProduct))
00079     return suite
00080 
00081 if __name__ == '__main__':
00082     unittest.main(defaultTest="test_suite")