Changeset 2806 in products


Ignore:
Timestamp:
Sep 13, 2010 3:59:31 PM (12 years ago)
Author:
mylan
Message:

#195: Added captcha field validation test in doctests

Location:
quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/README.txt

    r2805 r2806  
    5050    True 
    5151 
     52 
     53Now try to submit form with wrong captcha key. Error status message will 
     54be shown. 
     55 
     56    >>> browser.open(self.portal.absolute_url() + '/@@formlib-captcha-form') 
     57    >>> browser.getControl(name='form.captcha').value = "wrong captcha" 
     58    >>> browser.getControl(name='form..hashkey').value = self.hashkey 
     59    >>> browser.getControl(name="form.actions.save").click() 
     60    >>> "Type the code" in browser.contents 
     61    True 
     62    >>> "Please re-enter validation code." in browser.contents 
     63    True 
     64 
     65And now submit form with correct captcha key. 
     66 
     67    >>> browser.open(self.portal.absolute_url() + '/@@formlib-captcha-form') 
     68    >>> browser.getControl(name='form.captcha').value = self.captcha_word 
     69    >>> browser.getControl(name='form..hashkey').value = self.hashkey 
     70    >>> browser.getControl(name="form.actions.save").click() 
     71    >>> "Please re-enter validation code." in browser.contents 
     72    False 
     73 
     74No error shown. 
  • quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/tests/test_doctests.py

    r2801 r2806  
    1010from Products.PloneTestCase.layer import PloneSite 
    1111from Testing import ZopeTestCase as ztc 
     12 
     13from quintagroup.captcha.core.utils import * 
     14from quintagroup.captcha.core.tests.base import testPatch 
     15from quintagroup.captcha.core.tests.testWidget import addTestLayer 
    1216 
    1317class FormlibCaptchaLayer(PloneSite): 
     
    2832ptc.setupPloneSite(extension_profiles=['quintagroup.captcha.core:default',]) 
    2933 
    30  
    3134class FormlibCaptchaTestCase(ptc.FunctionalTestCase): 
    3235    layer = FormlibCaptchaLayer 
     36 
     37    def afterSetUp(self): 
     38        # prepare context 
     39        self.loginAsPortalOwner() 
     40        testPatch() 
     41        addTestLayer(self) 
     42        # prepare captcha data 
     43        captcha_key = self.portal.captcha_key 
     44        self.hashkey = self.portal.getCaptcha() 
     45        decrypted = decrypt(captcha_key, self.hashkey) 
     46        self.captcha_word = getWord(int(parseKey(decrypted)['key'])-1 ) 
     47 
    3348 
    3449def test_suite(): 
Note: See TracChangeset for help on using the changeset viewer.