Changeset 7285
- Timestamp:
- 6 Dec 2011, 15:51:18 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/tests/test_captcha.py
r7283 r7285 16 16 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 ## 18 from zope.component import getAdapter 18 from zope.component import getAdapter, getUtility 19 19 from zope.interface import verify 20 20 from zope.publisher.browser import TestRequest 21 21 from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase 22 22 from waeup.sirp.browser.captcha import ( 23 ICaptchaResponse, ICaptchaRequest, ICaptcha )23 ICaptchaResponse, ICaptchaRequest, ICaptcha, ICaptchaChooser) 24 24 from waeup.sirp.browser.captcha import ( 25 CaptchaResponse, CaptchaRequest, NullCaptcha )25 CaptchaResponse, CaptchaRequest, NullCaptcha, CaptchaChooser) 26 26 27 27 class CaptchaResponseTests(FunctionalTestCase): … … 88 88 return 89 89 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') 94 93 self.assertTrue(isinstance(captcha, NullCaptcha)) 95 94 return 95 96 class 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.