Back to index

plone3  3.1.7
testSetup.py
Go to the documentation of this file.
00001 #
00002 # Setup tests
00003 #
00004 
00005 import os, sys
00006 if __name__ == '__main__':
00007     execfile(os.path.join(sys.path[0], 'framework.py'))
00008 
00009 from Testing import ZopeTestCase
00010 from Products.ZCatalog.ZCatalog import ZCatalog
00011 
00012 ZopeTestCase.installProduct('ExtendedPathIndex')
00013 
00014 
00015 class TestSetup(ZopeTestCase.ZopeTestCase):
00016 
00017     def afterSetUp(self):
00018         self.folder._setObject('catalog', ZCatalog('catalog'))
00019         self.catalog = self.folder.catalog
00020 
00021     def assertIndexCreated(self, id):
00022         try:
00023             self.catalog.Indexes[id]
00024         except KeyError:
00025             self.fail('Failed to create index')
00026 
00027     def testAddIndex(self):
00028         factory = self.catalog.manage_addProduct['ExtendedPathIndex']
00029         factory.manage_addExtendedPathIndex(id='path')
00030         self.assertIndexCreated('path')
00031 
00032     def testAddIndexWithExtra(self):
00033         factory = self.catalog.manage_addProduct['ExtendedPathIndex']
00034         factory.manage_addExtendedPathIndex(id='path', extra={'indexed_attrs': 'foo'})
00035         self.assertIndexCreated('path')
00036 
00037 
00038 def test_suite():
00039     from unittest import TestSuite, makeSuite
00040     suite = TestSuite()
00041     suite.addTest(makeSuite(TestSetup))
00042     return suite
00043 
00044 if __name__ == '__main__':
00045     framework()