Changeset 672

Show
Ignore:
Timestamp:
11/30/06 09:23:51
Author:
crchemist
Message:

Added new test.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qPloneCaptchas/trunk/skins/plone_captchas/prefs_captchas_setup_form.cpt

    r671 r672  
    5555            </fieldset> 
    5656 
     57            <fieldset> 
     58                <legend i18n:translate="legend_setup_options">captcha image setup options</legend> 
     59                <div tal:define="ct here/getCaptchaType;"> 
     60                    <input name="static_captchas" 
     61                           id="use_static_captchas" 
     62                           type="radio" 
     63                           value="static" 
     64                           tal:attributes="checked python:test(ct=='static', 'checked', '')"/> 
     65                    <label for="use_static_captchas">Use static captchas</label> 
     66                    <br /> 
     67                    <input name="static_captchas" 
     68                           id="use_dynamic_captchas" 
     69                           type="radio" 
     70                           disabled="" 
     71                           value="dynamic" 
     72                           tal:attributes="checked python:test(ct=='dynamic', 'checked', ''); 
     73                                           disabled python:test(context.checkPIL(), '', 'disabled');"/> 
     74                    <label for="use_dynamic_captchas">Use dynamic captchas</label> 
     75                </div> 
     76            </fieldset> 
     77 
    5778            <div class="formControls"> 
    5879                <input type="hidden" name="form.submitted" value="1" /> 
  • qPloneCaptchas/trunk/tests/testCaptchaWidget.py

    r671 r672  
    3131        newSecurityManager(None, user) 
    3232        self.captcha_key = self.portal.captcha_key 
    33      
     33 
     34    def testImage(self): 
     35        path = '%s/discussion_reply_form'%self.absolute_url 
     36        resp1 = self.publish(path, self.basic_auth, request_method='GET').getBody() 
     37        patt = re.compile('<img\s+src="%s(/getCaptchaImage/[0-9a-fA-F]+)"'%self.portal.absolute_url()) 
     38        match_obj = patt.search(resp1) 
     39        img_url = match_obj.group(1) 
     40        content_type = self.publish('/plone'+img_url, self.basic_auth).getHeader('content-type') 
     41        self.assert_(content_type.startswith('image')) 
     42 
    3443    def testSubmitRightCaptcha(self): 
    3544        hashkey = self.portal.getCaptcha() 
     
    4756        self.assert_(not match_obj) 
    4857 
    49  
    50      
    5158    def testSubmitWrongCaptcha(self): 
    5259        hashkey = self.portal.getCaptcha() 
     
    6269        match_obj = patt.search(response) 
    6370        self.assert_(match_obj) 
    64      
     71 
    6572    def testSubmitRightCaptchaTwice(self): 
    6673        hashkey = self.portal.getCaptcha() 
     
    7885        match_obj = patt.match(response) 
    7986        self.assert_(not match_obj) 
    80      
     87 
    8188class TestInstallation(PloneTestCase.FunctionalTestCase): 
    8289 
     
    8491        self.loginAsPortalOwner() 
    8592        self.addProduct('qPloneCaptchas') 
    86      
     93 
    8794    def testCaptchaKey(self): 
    8895        ck = getattr(self.portal, 'captcha_key') 
    8996        self.assert_(ck) 
    9097        self.assertEqual(len(ck), 8) 
    91      
     98 
    9299    def testCaptchaTool(self): 
    93100        self.assert_('portal_captchas' in self.portal.objectIds()) 
    94      
     101 
    95102 
    96103def test_suite():