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

Last change on this file since 3121 was 3121, checked in by vmaksymiv, 13 years ago

pep8 fixes

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