[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 |
---|
[3154] | 10 | from Products.PloneTestCase.layer import PloneSite |
---|
[1999] | 11 | |
---|
[3154] | 12 | from quintagroup.plonecaptchas.config import PRODUCT_NAME |
---|
[1999] | 13 | |
---|
[2003] | 14 | # TESTING CONSTANTS |
---|
[1999] | 15 | CAPTCHA_KEY = 'captcha_key' |
---|
| 16 | CAPTCHAS_COUNT = 165 |
---|
[2498] | 17 | LAYERS = ['captchas_discussion', 'captchas_sendto_form', "captchas_contact_info"] |
---|
[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 | |
---|
[2476] | 24 | # register_form profile |
---|
| 25 | RF_PROFILE = 'profile-quintagroup.plonecaptchas:register_form' |
---|
[2024] | 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 | |
---|
[2476] | 59 | # Run register_form profile |
---|
| 60 | gs = getattr(portal, 'portal_setup', None) |
---|
| 61 | gs.runAllImportStepsFromProfile(RF_PROFILE) |
---|
[2024] | 62 | |
---|
[1999] | 63 | transaction.commit() |
---|
| 64 | |
---|
| 65 | @classmethod |
---|
| 66 | def tearDown(cls): |
---|
| 67 | ptc_setup._placefulTearDown() |
---|
| 68 | |
---|
[3154] | 69 | |
---|
[1999] | 70 | class TestCase(ptc.PloneTestCase): |
---|
| 71 | layer = Installed |
---|
| 72 | |
---|
| 73 | class TestCaseNotInstalled(ptc.PloneTestCase): |
---|
| 74 | layer = NotInstalled |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | class FunctionalTestCase(ptc.FunctionalTestCase): |
---|
| 78 | layer = Installed |
---|
| 79 | |
---|
| 80 | class FunctionalTestCaseNotInstalled(ptc.FunctionalTestCase): |
---|
| 81 | layer = NotInstalled |
---|