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

Source Code for Module icsemantic.langfallback.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.CMFCore.utils import getToolByName 
 19  from Products.Archetypes.utils import shasattr 
 20   
 21  from platecom.langview.config import * 
 22   
 23  import utils 
 24   
 25  # 
 26  # When ZopeTestCase configures Zope, it will *not* auto-load products in 
 27  # Products/. Instead, we have to use a statement such as: 
 28  # 
 29  #   ztc.installProduct('SimpleAttachment') 
 30  # 
 31  # This does *not* apply to products in eggs and Python packages (i.e. not in 
 32  # the Products.*) namespace. For that, see below. 
 33  # 
 34  # All of Plone's products are already set up by PloneTestCase. 
 35  # 
 36   
 37  ztc.installProduct('GenericSetup') 
 38  ztc.installProduct('PloneLanguageTool') 
 39  ztc.installProduct('LinguaPlone') 
40 41 @onsetup 42 -def setup_icsemantic.langfallback():
43 ztc.installProduct('Five') 44 fiveconfigure.debug_mode = True 45 zcml.load_config('configure.zcml', PACKAGE) 46 fiveconfigure.debug_mode = False 47 48 # MONKEYPATCH: everytime (until we figure out the problem where 49 # monkeypatch gets overwritten somewhere) 50 try: 51 from Products.Five import pythonproducts 52 pythonproducts.setupPythonProducts(None) 53 54 # MONKEYPATCH: arregla los problemas con el 55 # control panel y la instalacion de Five... 56 import App 57 App.ApplicationManager.ApplicationManager.Five=utils.Five 58 59 # MONKEYPATCH: arregla los problemas con el 60 # HTTP_REFERER en los tests funcionales. Tiene la 61 # contra de enviarnos al raiz del plone cada vez 62 # que un metodo depende de esa variable, pero es 63 # mejor que morir con una excepcion o llenar los 64 # tests de try blocks... 65 ztc.zopedoctest.functional.http=utils.http 66 except ImportError: 67 # Not needed in Plone 3 68 ztc.installPackage(PROJECTNAME)
69 70 setup_icsemantic.langfallback() 71 72 ptc.setupPloneSite(products=[PROJECTNAME,])
73 74 -class icSemanticTestCase(ptc.PloneTestCase):
75 """We use this base class for all the tests in this package. If necessary, 76 we can put common utility or setup code in here. This applies to unit 77 test cases. 78 """
79
80 -class icSemanticFunctionalTestCase(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 afterSetUp(self):
85 # Run all import steps 86 setup_tool = getToolByName(self.portal, 'portal_setup') 87 profile_name = 'profile-' + PROJECTNAME + ':tests' 88 if shasattr(setup_tool, 'runAllImportStepsFromProfile'): 89 # Plone 3 90 setup_tool.runAllImportStepsFromProfile(profile_name) 91 else: 92 # Plone 2.5. Would work on 3.0 too, but then it gives tons of 93 # DeprecationWarnings when running the tests, causing failures 94 # to drown in the noise. 95 old_context = setup_tool.getImportContextID() 96 setup_tool.setImportContext(profile_name) 97 setup_tool.runAllImportSteps() 98 setup_tool.setImportContext(old_context) 99 100 super(icSemanticFunctionalTestCase, self).afterSetUp()
101