1 | import transaction |
---|
2 | |
---|
3 | from Products.Five import zcml |
---|
4 | from Products.Five import fiveconfigure |
---|
5 | |
---|
6 | from Testing import ZopeTestCase as ztc |
---|
7 | |
---|
8 | from Products.PloneTestCase import setup as ptc_setup |
---|
9 | from Products.PloneTestCase import PloneTestCase as ptc |
---|
10 | from Products.PloneTestCase.layer import PloneSite |
---|
11 | |
---|
12 | from quintagroup.plonecaptchas.config import PRODUCT_NAME |
---|
13 | |
---|
14 | # TESTING CONSTANTS |
---|
15 | CAPTCHA_KEY = 'captcha_key' |
---|
16 | CAPTCHAS_COUNT = 165 |
---|
17 | LAYERS = ['captchas_discussion', 'captchas_sendto_form', 'captchas_join_form'] |
---|
18 | |
---|
19 | TOOL_ICON = 'skins/plone_captchas/tool.gif' |
---|
20 | TOOL_ID = 'portal_captchas' |
---|
21 | CONFIGLET_ID = "qpc_tool" |
---|
22 | PROPERTY_SHEET = 'qPloneCaptchas' |
---|
23 | |
---|
24 | # join_form profile prefix |
---|
25 | JF_PROFILE_PREFIX = 'profile-quintagroup.plonecaptchas:join_form_plone_' |
---|
26 | |
---|
27 | ptc.setupPloneSite() |
---|
28 | |
---|
29 | |
---|
30 | class 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 | |
---|
46 | class 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 | |
---|
81 | class TestCase(ptc.PloneTestCase): |
---|
82 | layer = Installed |
---|
83 | |
---|
84 | |
---|
85 | class TestCaseNotInstalled(ptc.PloneTestCase): |
---|
86 | layer = NotInstalled |
---|
87 | |
---|
88 | |
---|
89 | class FunctionalTestCase(ptc.FunctionalTestCase): |
---|
90 | layer = Installed |
---|
91 | |
---|
92 | |
---|
93 | class FunctionalTestCaseNotInstalled(ptc.FunctionalTestCase): |
---|
94 | layer = NotInstalled |
---|