source: products/quintagroup.plonecaptchas/branches/split2packs/quintagroup/plonecaptchas/tests/base.py @ 2024

Last change on this file since 2024 was 2024, checked in by mylan, 14 years ago

#175: Tests: updated tests after split join_form skin layer

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