Package platecom :: Package utils :: Package tests :: Module base
[hide private]
[frames] | no frames]

Source Code for Module iccommunity.core.tests.base

 1  """Test setup for integration and functional tests. 
 2   
 3  When we import PloneTestCase and then call setupPloneSite(), all of Plone's 
 4  products are loaded, and a Plone site will be created. This happens at module 
 5  level, which makes it faster to run each test, but slows down test runner 
 6  startup. 
 7  """ 
 8  import os, sys 
 9  from App import Common 
10   
11  from Products.Five import zcml 
12  from Products.Five import fiveconfigure 
13   
14  from Testing import ZopeTestCase as ztc 
15   
16  from Products.PloneTestCase import PloneTestCase as ptc 
17  from Products.PloneTestCase.layer import onsetup 
18  from Products.PloneTestCase.layer import ZCMLLayer 
19   
20  from platecom.utils.config import * 
21   
22  import utils 
23   
24  # 
25  # When ZopeTestCase configures Zope, it will *not* auto-load products in 
26  # Products/. Instead, we have to use a statement such as: 
27  # 
28  #   ztc.installProduct('SimpleAttachment') 
29  # 
30  # This does *not* apply to products in eggs and Python packages (i.e. not in 
31  # the Products.*) namespace. For that, see below. 
32  # 
33  # All of Plone's products are already set up by PloneTestCase. 
34  # 
35   
36  ztc.installProduct('GenericSetup') 
37  ztc.installProduct('PloneLanguageTool') 
38  ztc.installProduct('LinguaPlone') 
39 40 @onsetup 41 -def setup_iccommunity.core():
42 ztc.installProduct('Five') 43 fiveconfigure.debug_mode = True 44 zcml.load_config('configure.zcml', PACKAGE) 45 fiveconfigure.debug_mode = False 46 47 # MONKEYPATCH: everytime (until we figure out the problem where 48 # monkeypatch gets overwritten somewhere) 49 try: 50 from Products.Five import pythonproducts 51 pythonproducts.setupPythonProducts(None) 52 53 # MONKEYPATCH: arregla los problemas con el 54 # control panel y la instalacion de Five... 55 import App 56 App.ApplicationManager.ApplicationManager.Five=utils.Five 57 58 # MONKEYPATCH: arregla los problemas con el 59 # HTTP_REFERER en los tests funcionales. Tiene la 60 # contra de enviarnos al raiz del plone cada vez 61 # que un metodo depende de esa variable, pero es 62 # mejor que morir con una excepcion o llenar los 63 # tests de try blocks... 64 ztc.zopedoctest.functional.http=utils.http 65 except ImportError: 66 # Not needed in Plone 3 67 ztc.installPackage(PROJECTNAME)
68 69 setup_iccommunity.core() 70 71 ptc.setupPloneSite(products=[PROJECTNAME,])
72 73 -class icCommunityTestCase(ptc.PloneTestCase, ztc.ZopeTestCase):
74 """We use this base class for all the tests in this package. If necessary, 75 we can put common utility or setup code in here. This applies to unit 76 test cases. 77 """
78 # layer = ZCMLLayer
79 80 -class icCommunityFunctionalTestCase(ptc.FunctionalTestCase):
81 """We use this class for functional integration tests that use doctest 82 syntax. Again, we can put basic common utility or setup code in here. 83 """
84 - def setUp(self):
85 # self.setRoles(['Manager',]) 86 # portal.invokeFactory('Folder', id='sb') 87 # self.sb = portal.sb 88 # self.sb_url = sb.absolute_url() 89 90 super(icCommunityFunctionalTestCase, self).setUp()
91