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', |
---|
18 | 'captchas_contact_info'] |
---|
19 | |
---|
20 | TOOL_ICON = 'skins/plone_captchas/tool.gif' |
---|
21 | TOOL_ID = 'portal_captchas' |
---|
22 | CONFIGLET_ID = "qpc_tool" |
---|
23 | PROPERTY_SHEET = 'qPloneCaptchas' |
---|
24 | |
---|
25 | # register_form profile |
---|
26 | RF_PROFILE = 'profile-quintagroup.plonecaptchas:register_form' |
---|
27 | |
---|
28 | ptc.setupPloneSite() |
---|
29 | |
---|
30 | |
---|
31 | class NotInstalled(PloneSite): |
---|
32 | """ Only package register, without installation into portal |
---|
33 | """ |
---|
34 | |
---|
35 | @classmethod |
---|
36 | def setUp(cls): |
---|
37 | fiveconfigure.debug_mode = True |
---|
38 | import quintagroup.captcha.core |
---|
39 | import quintagroup.plonecaptchas |
---|
40 | zcml.load_config('configure.zcml', quintagroup.captcha.core) |
---|
41 | zcml.load_config('configure.zcml', quintagroup.plonecaptchas) |
---|
42 | fiveconfigure.debug_mode = False |
---|
43 | ztc.installPackage('quintagroup.captcha.core') |
---|
44 | ztc.installPackage('quintagroup.plonecaptchas') |
---|
45 | |
---|
46 | |
---|
47 | class Installed(NotInstalled): |
---|
48 | """ Install product into the portal |
---|
49 | """ |
---|
50 | @classmethod |
---|
51 | def setUp(cls): |
---|
52 | app = ztc.app() |
---|
53 | portal = app[ptc_setup.portal_name] |
---|
54 | |
---|
55 | # Sets the local site/manager |
---|
56 | ptc_setup._placefulSetUp(portal) |
---|
57 | # Install PROJECT |
---|
58 | qi = getattr(portal, 'portal_quickinstaller', None) |
---|
59 | qi.installProduct(PRODUCT_NAME) |
---|
60 | |
---|
61 | # Run register_form profile |
---|
62 | gs = getattr(portal, 'portal_setup', None) |
---|
63 | gs.runAllImportStepsFromProfile(RF_PROFILE) |
---|
64 | |
---|
65 | transaction.commit() |
---|
66 | |
---|
67 | @classmethod |
---|
68 | def tearDown(cls): |
---|
69 | ptc_setup._placefulTearDown() |
---|
70 | |
---|
71 | |
---|
72 | class TestCase(ptc.PloneTestCase): |
---|
73 | layer = Installed |
---|
74 | |
---|
75 | |
---|
76 | class TestCaseNotInstalled(ptc.PloneTestCase): |
---|
77 | layer = NotInstalled |
---|
78 | |
---|
79 | |
---|
80 | class FunctionalTestCase(ptc.FunctionalTestCase): |
---|
81 | layer = Installed |
---|
82 | |
---|
83 | |
---|
84 | class FunctionalTestCaseNotInstalled(ptc.FunctionalTestCase): |
---|
85 | layer = NotInstalled |
---|