Back to index

plone3  3.1.7
testCMFCalendar.py
Go to the documentation of this file.
00001 #
00002 # Tests a CMF product
00003 #
00004 
00005 import os, sys
00006 if __name__ == '__main__':
00007     execfile(os.path.join(sys.path[0], 'framework.py'))
00008 
00009 from Products.CMFTestCase import CMFTestCase
00010 
00011 CMFTestCase.installProduct('CMFCalendar')
00012 
00013 profiles = ('CMFCalendar:default',)
00014 
00015 if CMFTestCase.CMF21:
00016     profiles = ('Products.CMFCalendar:default',)
00017 
00018 if CMFTestCase.CMF16:
00019     CMFTestCase.setupCMFSite(extension_profiles=profiles)
00020 else:
00021     CMFTestCase.setupCMFSite(products=('CMFCalendar',))
00022 
00023 
00024 class TestCalendar(CMFTestCase.CMFTestCase):
00025 
00026     def afterSetUp(self):
00027         self.catalog = self.portal.portal_catalog
00028 
00029     def testToolsInstalled(self):
00030         self.failUnless(hasattr(self.portal, 'portal_calendar'))
00031 
00032     if not CMFTestCase.CMF21:
00033 
00034         def testSkinsInstalled(self):
00035             self.failUnless(hasattr(self.portal, 'event_view'))
00036 
00037     def testTypesInstalled(self):
00038         types = self.portal.portal_types.objectIds()
00039         self.failUnless('Event' in types)
00040 
00041     def testIndexesInstalled(self):
00042         try:
00043             self.catalog._catalog.getIndex('start')
00044         except KeyError:
00045             self.fail()
00046 
00047     def testCreateEvent(self):
00048         self.folder.invokeFactory('Event', id='lunch',
00049                                   start_date='2005-01-11 08:00',
00050                                   end_date='2005-01-12 14:00')
00051 
00052         r = self.catalog(start={'query': '2005-01-11 09:00', 'range': 'max'})
00053 
00054         self.assert_(r)
00055         self.assertEqual(r[0].getId, 'lunch')
00056 
00057 
00058 def test_suite():
00059     from unittest import TestSuite, makeSuite
00060     suite = TestSuite()
00061     suite.addTest(makeSuite(TestCalendar))
00062     return suite
00063 
00064 if __name__ == '__main__':
00065     framework()
00066