Ignore:
Timestamp:
6 Dec 2011, 22:33:31 (13 years ago)
Author:
uli
Message:

Add test base for captcha tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/tests/test_captcha.py

    r7291 r7294  
    6363        return
    6464
    65 class NullCaptchaTests(FunctionalTestCase):
    66 
    67     layer = FunctionalLayer
     65class CaptchaTestBase(object):
    6866
    6967    def test_ifaces(self):
    7068        # make sure we implement the promised interfaces
    71         obj = NullCaptcha()
    72         verify.verifyClass(ICaptcha, NullCaptcha)
     69        obj = self.factory()
     70        verify.verifyClass(ICaptcha, self.factory)
    7371        verify.verifyObject(ICaptcha, obj)
    7472        return
     73
     74    def test_utility(self):
     75        # the null captcha is also registered as a utility for ICaptcha
     76        captcha = getUtility(ICaptcha, name=self.name)
     77        self.assertTrue(isinstance(captcha, self.factory))
     78        return
     79
     80class NullCaptchaTests(FunctionalTestCase, CaptchaTestBase):
     81
     82    layer = FunctionalLayer
     83
     84    factory = NullCaptcha
     85    name = 'No captcha'
    7586
    7687    def test_verify(self):
    7788        # null captchas accept any input request
    78         captcha = NullCaptcha()
     89        captcha = self.factory()
    7990        result1 = captcha.verify(CaptchaRequest('my-sol', 'my-challenge'))
    8091        result2 = captcha.verify(CaptchaRequest(None, None))
     
    8596    def test_display(self):
    8697        # null captchas do not generate additional HTML code
    87         captcha = NullCaptcha()
     98        captcha = self.factory()
    8899        result = captcha.display()
    89100        self.assertEqual(result, u'')
    90101        return
    91102
    92     def test_utility(self):
    93         # the null captcha is also registered as a utility for ICaptcha
    94         captcha = getUtility(ICaptcha, name='No captcha')
    95         self.assertTrue(isinstance(captcha, NullCaptcha))
    96         return
     103class TestCaptchaTests(FunctionalTestCase):
     104
     105    layer = FunctionalLayer
    97106
    98107class CaptchaChooserTests(FunctionalTestCase):
    99108    # These tests do not require a site setup
     109    # See testsuite below for insite tests.
    100110
    101111    layer = FunctionalLayer
Note: See TracChangeset for help on using the changeset viewer.