source: products/quintagroup.plonecaptchas/trunk/quintagroup/plonecaptchas/tests/base.py @ 3162

Last change on this file since 3162 was 3162, checked in by vmaksymiv, 13 years ago

pep8 fixes

  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
1import transaction
2
3from Products.Five import zcml
4from Products.Five import fiveconfigure
5
6from Testing import ZopeTestCase as ztc
7
8from Products.PloneTestCase import setup as ptc_setup
9from Products.PloneTestCase import PloneTestCase as ptc
10from Products.PloneTestCase.layer import PloneSite
11
12from quintagroup.plonecaptchas.config import PRODUCT_NAME
13
14# TESTING CONSTANTS
15CAPTCHA_KEY = 'captcha_key'
16CAPTCHAS_COUNT = 165
17LAYERS = ['captchas_discussion', 'captchas_sendto_form', 'captchas_join_form']
18
19TOOL_ICON = 'skins/plone_captchas/tool.gif'
20TOOL_ID = 'portal_captchas'
21CONFIGLET_ID = "qpc_tool"
22PROPERTY_SHEET = 'qPloneCaptchas'
23
24# join_form profile prefix
25JF_PROFILE_PREFIX = 'profile-quintagroup.plonecaptchas:join_form_plone_'
26
27ptc.setupPloneSite()
28
29
30class NotInstalled(PloneSite):
31    """ Only package register, without installation into portal
32    """
33
34    @classmethod
35    def setUp(cls):
36        fiveconfigure.debug_mode = True
37        import quintagroup.captcha.core
38        import quintagroup.plonecaptchas
39        zcml.load_config('configure.zcml', quintagroup.captcha.core)
40        zcml.load_config('configure.zcml', quintagroup.plonecaptchas)
41        fiveconfigure.debug_mode = False
42        ztc.installPackage('quintagroup.plonecaptchas')
43        ztc.installPackage('quintagroup.captcha.core')
44
45
46class Installed(NotInstalled):
47    """ Install product into the portal
48    """
49    @classmethod
50    def setUp(cls):
51        app = ztc.app()
52        portal = app[ptc_setup.portal_name]
53
54        # Sets the local site/manager
55        ptc_setup._placefulSetUp(portal)
56        # Install PROJECT
57        qi = getattr(portal, 'portal_quickinstaller', None)
58        qi.installProduct(PRODUCT_NAME)
59
60        # Install Join Form layer, depends on Plone version
61        js_layer = None
62        if getattr(ptc_setup, 'PLONE33', 0):
63            js_layer = JF_PROFILE_PREFIX + '33'
64        elif getattr(ptc_setup, 'PLONE32', 0):
65            js_layer = JF_PROFILE_PREFIX + '31_32'
66        elif getattr(ptc_setup, 'PLONE31', 0):
67            js_layer = JF_PROFILE_PREFIX + '31_32'
68        elif getattr(ptc_setup, 'PLONE30', 0):
69            js_layer = JF_PROFILE_PREFIX + '30'
70        if js_layer is not None:
71            gs = getattr(portal, 'portal_setup', None)
72            gs.runAllImportStepsFromProfile(js_layer)
73
74        transaction.commit()
75
76    @classmethod
77    def tearDown(cls):
78        ptc_setup._placefulTearDown()
79
80
81class TestCase(ptc.PloneTestCase):
82    layer = Installed
83
84
85class TestCaseNotInstalled(ptc.PloneTestCase):
86    layer = NotInstalled
87
88
89class FunctionalTestCase(ptc.FunctionalTestCase):
90    layer = Installed
91
92
93class FunctionalTestCaseNotInstalled(ptc.FunctionalTestCase):
94    layer = NotInstalled
Note: See TracBrowser for help on using the repository browser.