Changeset 7285 for main/waeup.sirp/trunk


Ignore:
Timestamp:
6 Dec 2011, 15:51:18 (13 years ago)
Author:
uli
Message:

Update tests.

File:
1 edited

Legend:

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

    r7283 r7285  
    1616## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1717##
    18 from zope.component import getAdapter
     18from zope.component import getAdapter, getUtility
    1919from zope.interface import verify
    2020from zope.publisher.browser import TestRequest
    2121from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase
    2222from waeup.sirp.browser.captcha import (
    23     ICaptchaResponse, ICaptchaRequest, ICaptcha)
     23    ICaptchaResponse, ICaptchaRequest, ICaptcha, ICaptchaChooser)
    2424from waeup.sirp.browser.captcha import (
    25     CaptchaResponse, CaptchaRequest, NullCaptcha)
     25    CaptchaResponse, CaptchaRequest, NullCaptcha, CaptchaChooser)
    2626
    2727class CaptchaResponseTests(FunctionalTestCase):
     
    8888        return
    8989
    90     def test_adapter(self):
    91         # the null captcha is also registered as an adapter to IHTTPRequest
    92         request = TestRequest()
    93         captcha = getAdapter(request, name='No captcha')
     90    def test_utility(self):
     91        # the null captcha is also registered as a utility for ICaptcha
     92        captcha = getUtility(ICaptcha, name='No captcha')
    9493        self.assertTrue(isinstance(captcha, NullCaptcha))
    9594        return
     95
     96class CaptchaChooserTests(FunctionalTestCase):
     97
     98    layer = FunctionalLayer
     99
     100    def test_ifaces(self):
     101        # make sure we implement the promised interfaces
     102        obj = CaptchaChooser()
     103        verify.verifyClass(ICaptchaChooser, CaptchaChooser)
     104        verify.verifyObject(ICaptchaChooser, obj)
     105        return
     106
     107    def test_utility(self):
     108        # the global captcha chooser is registered as a global utility
     109        result = getUtility(ICaptchaChooser)
     110        self.assertTrue(isinstance(result, CaptchaChooser))
     111        return
     112
     113    def test_get_avail_captchas(self):
     114        # we can get a dict of available captchas.
     115        chooser = getUtility(ICaptchaChooser)
     116        result = dict(chooser.getAvailCaptchas())
     117        no_captcha = result.get('No captcha', None)
     118        self.assertTrue(no_captcha is not None)
     119        default_captcha = result.get(u'', None)
     120        self.assertTrue(default_captcha is None)
     121        return
Note: See TracChangeset for help on using the changeset viewer.