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