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
27
28
29
30
31
32
33
34
35
36
37 ztc.installProduct('GenericSetup')
38 ztc.installProduct('PloneLanguageTool')
39 ztc.installProduct('LinguaPlone')
43 ztc.installProduct('Five')
44 fiveconfigure.debug_mode = True
45 zcml.load_config('configure.zcml', PACKAGE)
46 fiveconfigure.debug_mode = False
47
48
49
50 try:
51 from Products.Five import pythonproducts
52 pythonproducts.setupPythonProducts(None)
53
54
55
56 import App
57 App.ApplicationManager.ApplicationManager.Five=utils.Five
58
59
60
61
62
63
64
65 ztc.zopedoctest.functional.http=utils.http
66 except ImportError:
67
68 ztc.installPackage(PROJECTNAME)
69
70 setup_icsemantic.langfallback()
71
72 ptc.setupPloneSite(products=[PROJECTNAME,])
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
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 """
85
86 setup_tool = getToolByName(self.portal, 'portal_setup')
87 profile_name = 'profile-' + PROJECTNAME + ':tests'
88 if shasattr(setup_tool, 'runAllImportStepsFromProfile'):
89
90 setup_tool.runAllImportStepsFromProfile(profile_name)
91 else:
92
93
94
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