Changeset 7307 for main/waeup.sirp/trunk/src/waeup/sirp
- Timestamp:
- 7 Dec 2011, 16:39:01 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/browser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/captcha.py
r7306 r7307 94 94 """ 95 95 96 class ICaptcha Chooser(Interface):96 class ICaptchaManager(Interface): 97 97 """A chooser that collects available captchas. 98 98 """ … … 108 108 # Global captcha chooser 109 109 # 110 class Captcha Chooser(grok.GlobalUtility):111 112 grok.implements(ICaptcha Chooser)110 class CaptchaManager(grok.GlobalUtility): 111 112 grok.implements(ICaptchaManager) 113 113 114 114 def getAvailCaptchas(self): … … 265 265 * get the currently site-wide selected captcha type by doing:: 266 266 267 mycaptcha = getUtility(ICaptcha Chooser).getCaptcha()267 mycaptcha = getUtility(ICaptchaManager).getCaptcha() 268 268 269 269 * if you want a specific captcha type (like ReCaptcha):: -
main/waeup.sirp/trunk/src/waeup/sirp/browser/tests/test_captcha.py
r7302 r7307 23 23 from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase 24 24 from waeup.sirp.browser.captcha import ( 25 ICaptchaResponse, ICaptchaRequest, ICaptcha, ICaptcha Chooser)25 ICaptchaResponse, ICaptchaRequest, ICaptcha, ICaptchaManager) 26 26 from waeup.sirp.browser.captcha import ( 27 27 CaptchaResponse, CaptchaRequest, NullCaptcha, StaticCaptcha, ReCaptcha, 28 Captcha Chooser)28 CaptchaManager) 29 29 30 30 class CaptchaResponseTests(FunctionalTestCase): … … 180 180 return 181 181 182 class Captcha ChooserTests(FunctionalTestCase):182 class CaptchaManagerTests(FunctionalTestCase): 183 183 # These tests do not require a site setup 184 184 # See testsuite below for insite tests. … … 188 188 def test_ifaces(self): 189 189 # make sure we implement the promised interfaces 190 obj = Captcha Chooser()191 verify.verifyClass(ICaptcha Chooser, CaptchaChooser)192 verify.verifyObject(ICaptcha Chooser, obj)190 obj = CaptchaManager() 191 verify.verifyClass(ICaptchaManager, CaptchaManager) 192 verify.verifyObject(ICaptchaManager, obj) 193 193 return 194 194 195 195 def test_utility(self): 196 196 # the global captcha chooser is registered as a global utility 197 result = getUtility(ICaptcha Chooser)198 self.assertTrue(isinstance(result, Captcha Chooser))197 result = getUtility(ICaptchaManager) 198 self.assertTrue(isinstance(result, CaptchaManager)) 199 199 return 200 200 201 201 def test_get_avail_captchas(self): 202 202 # we can get a dict of available captchas. 203 chooser = getUtility(ICaptcha Chooser)203 chooser = getUtility(ICaptchaManager) 204 204 result = dict(chooser.getAvailCaptchas()) 205 205 no_captcha = result.get('No captcha', None) … … 212 212 # if there is no site set, we get the default captcha 213 213 setSite(None) 214 chooser = getUtility(ICaptcha Chooser)214 chooser = getUtility(ICaptchaManager) 215 215 result = chooser.getCaptcha() 216 216 default = getUtility(ICaptcha) … … 221 221 pass 222 222 223 class Captcha ChooserTestsWithSite(FunctionalTestCase):223 class CaptchaManagerTestsWithSite(FunctionalTestCase): 224 224 225 225 layer = FunctionalLayer 226 226 227 227 def setUp(self): 228 super(Captcha ChooserTestsWithSite, self).setUp()228 super(CaptchaManagerTestsWithSite, self).setUp() 229 229 self.getRootFolder()['app'] = FakeSite() 230 230 self.site = self.getRootFolder()['app'] … … 232 232 233 233 def tearDown(self): 234 super(Captcha ChooserTestsWithSite, self).tearDown()234 super(CaptchaManagerTestsWithSite, self).tearDown() 235 235 clearSite(self.site) 236 236 return … … 240 240 # the default captcha 241 241 setSite(self.site) 242 chooser = getUtility(ICaptcha Chooser)242 chooser = getUtility(ICaptchaManager) 243 243 result = chooser.getCaptcha() 244 244 default = getUtility(ICaptcha) … … 251 251 setSite(self.site) 252 252 self.site['configuration'] = dict() 253 chooser = getUtility(ICaptcha Chooser)253 chooser = getUtility(ICaptchaManager) 254 254 result = chooser.getCaptcha() 255 255 default = getUtility(ICaptcha) … … 262 262 setSite(self.site) 263 263 self.site['configuration'] = dict(captcha='invalid name') 264 chooser = getUtility(ICaptcha Chooser)264 chooser = getUtility(ICaptchaManager) 265 265 result = chooser.getCaptcha() 266 266 default = getUtility(ICaptcha) … … 273 273 setSite(self.site) 274 274 self.site['configuration'] = dict(captcha='No captcha') 275 chooser = getUtility(ICaptcha Chooser)275 chooser = getUtility(ICaptchaManager) 276 276 result = chooser.getCaptcha() 277 277 no_captcha = getUtility(ICaptcha, name='No captcha')
Note: See TracChangeset for help on using the changeset viewer.