Back to index

plone3  3.1.7
tests.py
Go to the documentation of this file.
00001 # we want to test each configuration to make sure what we think is
00002 # happening does.
00003 import unittest
00004 from Products.Five import zcml
00005 from Products.Five import fiveconfigure
00006 from Products.PloneTestCase import ptc, five
00007 from Products.PloneTestCase.layer import ZCML, PloneSite
00008 from wicked.at.tests import wickedtestcase as wtc
00009 from wicked.at.tests import test_cache, test_linking
00010 from wicked.at.tests.wickedtestcase import WickedSite
00011 from wicked.fieldevent import meta 
00012 import wicked.plone as here
00013 from Products.PloneTestCase.layer import PloneSite 
00014 
00015 from Testing import ZopeTestCase
00016 
00017 # oh ghost of Tiran forgive me, but type substitution is important
00018 test_klasses = (test_cache.TestLinkCache,
00019                 test_linking.TestDocCreation,
00020                 test_linking.TestWikiLinking,
00021                 test_linking.TestLinkNormalization,
00022                 test_linking.TestRemoteLinking)
00023 
00024 ptc.setupPloneSite()
00025 
00026 # this manhandles the zcml a bit
00027     
00028 
00029 from registration import basic_type_regs
00030 
00031 class ZCMLLayer(PloneSite):
00032     @classmethod
00033     def setUp(cls):
00034         fiveconfigure.debug_mode = True
00035         zcml.load_config('all-at.zcml', here)
00036         fiveconfigure.debug_mode = False
00037 
00038 class SelectiveATCT(PloneSite):
00039 
00040     @classmethod
00041     def setUp(cls):
00042         app = ZopeTestCase.app()
00043         plone = app.plone
00044         for factory in basic_type_regs:
00045             factory(plone).handle()
00046         import transaction as txn
00047         txn.commit()
00048         ZopeTestCase.close(app)
00049 
00050     @classmethod
00051     def tearDown(cls):
00052         """thanks to the zcml load, teardown is not an option"""
00053         import transaction as txn
00054         app = ZopeTestCase.app()
00055         plone = app.plone
00056         for factory in basic_type_regs:
00057             factory(plone).handle(unregister=True)
00058         txn.commit()
00059         ZopeTestCase.close(app)
00060 
00061 
00062 def make_wicked_suite(klasses, layer, content_type="Document", field="text"):
00063     """a factory to spitting out a new test class and new suite for
00064     these functional tests"""
00065     suite = unittest.TestSuite()
00066 
00067     for klass in klasses:
00068         newname = '%s_%s' %(klass.__name__, layer.__name__)
00069         bases = (klass,)
00070         newdict = dict(wicked_type=content_type,
00071                        wicked_field=field,
00072                        layer=layer,
00073                        setter='setText')
00074         newklass = type(newname, bases, newdict)
00075         new = unittest.makeSuite(newklass)
00076         suite.addTest(new)
00077     return suite
00078 
00079         
00080 def test_suite():
00081     suites = make_wicked_suite(test_klasses, SelectiveATCT) 
00082     return unittest.TestSuite(suites)
00083     
00084