[2801] | 1 | import unittest |
---|
| 2 | import doctest |
---|
| 3 | |
---|
| 4 | from zope.interface import Interface |
---|
| 5 | |
---|
| 6 | from Products.Five import zcml |
---|
| 7 | from Products.Five import fiveconfigure |
---|
| 8 | |
---|
| 9 | from Products.PloneTestCase import PloneTestCase as ptc |
---|
| 10 | from Products.PloneTestCase.layer import PloneSite |
---|
| 11 | from Testing import ZopeTestCase as ztc |
---|
| 12 | |
---|
[2806] | 13 | from quintagroup.captcha.core.utils import * |
---|
| 14 | from quintagroup.captcha.core.tests.base import testPatch |
---|
| 15 | from quintagroup.captcha.core.tests.testWidget import addTestLayer |
---|
| 16 | |
---|
[2801] | 17 | class FormlibCaptchaLayer(PloneSite): |
---|
| 18 | @classmethod |
---|
| 19 | def setUp(cls): |
---|
| 20 | fiveconfigure.debug_mode = True |
---|
| 21 | import quintagroup.captcha.core |
---|
| 22 | import quintagroup.formlib.captcha |
---|
| 23 | zcml.load_config('configure.zcml', quintagroup.formlib.captcha) |
---|
| 24 | zcml.load_config('tests.zcml', quintagroup.formlib.captcha.tests) |
---|
| 25 | fiveconfigure.debug_mode = False |
---|
| 26 | ztc.installPackage('quintagroup.captcha.core') |
---|
| 27 | |
---|
| 28 | @classmethod |
---|
| 29 | def tearDown(cls): |
---|
| 30 | pass |
---|
| 31 | |
---|
| 32 | ptc.setupPloneSite(extension_profiles=['quintagroup.captcha.core:default',]) |
---|
| 33 | |
---|
| 34 | class FormlibCaptchaTestCase(ptc.FunctionalTestCase): |
---|
| 35 | layer = FormlibCaptchaLayer |
---|
| 36 | |
---|
[2806] | 37 | def afterSetUp(self): |
---|
| 38 | # prepare context |
---|
| 39 | self.loginAsPortalOwner() |
---|
| 40 | testPatch() |
---|
| 41 | addTestLayer(self) |
---|
| 42 | # prepare captcha data |
---|
| 43 | captcha_key = self.portal.captcha_key |
---|
| 44 | self.hashkey = self.portal.getCaptcha() |
---|
| 45 | decrypted = decrypt(captcha_key, self.hashkey) |
---|
| 46 | self.captcha_word = getWord(int(parseKey(decrypted)['key'])-1 ) |
---|
| 47 | |
---|
| 48 | |
---|
[2801] | 49 | def test_suite(): |
---|
| 50 | return unittest.TestSuite([ |
---|
| 51 | |
---|
| 52 | # Demonstrate the main content types |
---|
| 53 | ztc.ZopeDocFileSuite( |
---|
| 54 | 'README.txt', package='quintagroup.formlib.captcha', |
---|
| 55 | test_class=FormlibCaptchaTestCase, |
---|
| 56 | optionflags=doctest.REPORT_ONLY_FIRST_FAILURE | doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS), |
---|
| 57 | |
---|
| 58 | ]) |
---|
| 59 | |
---|
| 60 | if __name__ == '__main__': |
---|
| 61 | unittest.main(defaultTest='test_suite') |
---|