source: products/quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/tests/test_doctests.py @ 3124

Last change on this file since 3124 was 3124, checked in by vmaksymiv, 11 years ago

pylint fixes

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1import unittest
2import doctest
3
4from Products.Five import zcml
5from Products.Five import fiveconfigure
6
7from Products.PloneTestCase import PloneTestCase as ptc
8from Products.PloneTestCase.layer import PloneSite
9from Testing import ZopeTestCase as ztc
10
11from quintagroup.captcha.core.utils import decrypt, parseKey, getWord
12from quintagroup.captcha.core.tests.base import testPatch
13from quintagroup.captcha.core.tests.testWidget import addTestLayer
14
15
16class FormlibCaptchaLayer(PloneSite):
17    @classmethod
18    def setUp(cls):
19        fiveconfigure.debug_mode = True
20        import quintagroup.captcha.core
21        import quintagroup.formlib.captcha
22        zcml.load_config('configure.zcml', quintagroup.formlib.captcha)
23        zcml.load_config('tests.zcml', quintagroup.formlib.captcha.tests)
24        fiveconfigure.debug_mode = False
25        ztc.installPackage('quintagroup.captcha.core')
26
27    @classmethod
28    def tearDown(cls):
29        pass
30
31ptc.setupPloneSite(extension_profiles=['quintagroup.captcha.core:default', ])
32
33
34class FormlibCaptchaTestCase(ptc.FunctionalTestCase):
35    layer = FormlibCaptchaLayer
36
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
49def 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 | \
57                        doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS),
58        ])
59
60if __name__ == '__main__':
61    unittest.main(defaultTest='test_suite')
Note: See TracBrowser for help on using the repository browser.