Changeset 1975 in products


Ignore:
Timestamp:
Mar 22, 2010 8:31:15 PM (14 years ago)
Author:
mylan
Message:

#172: Fix breakage of right captcha submiting test

Location:
quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests
Files:
10 added
2 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/base.py

    r1957 r1975  
    1313from Products.PloneTestCase.PloneTestCase import default_password 
    1414 
    15 from Products.CMFCore.utils import getToolByName 
    16  
    1715from quintagroup.captcha.core.config import * 
    1816from quintagroup.captcha.core.utils import getWord, decrypt, parseKey 
     17 
     18# PATCH dictionary for captcha testing 
     19from Products.CMFCore.utils import getToolByName 
     20class TestData(object): 
     21    words = """heart 
     22glass 
     23blue 
     24false 
     25burn 
     26""" 
     27 
     28from quintagroup.captcha.core import utils 
     29utils.basic_english = TestData() 
     30utils.CAPTCHAS_COUNT = len(utils.basic_english.words.split()) 
     31# END OF PATCH 
    1932 
    2033@onsetup 
  • quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testWidget.py

    r1957 r1975  
    4444    def testSubmitRightCaptcha(self): 
    4545        hashkey = self.portal.getCaptcha() 
    46         key = getWord(int(parseKey(decrypt(self.captcha_key, hashkey))['key'])) 
     46        # index of word number starts from 1, but index of dictionary starts from 0 
     47        key = getWord(int(parseKey(decrypt(self.captcha_key, hashkey))['key'])-1 ) 
    4748        parameters = 'form.submitted=1&key=%s' % key 
    4849        path = '%s/test_form?%s' % (self.absolute_url, parameters) 
     
    5051                 'form.button.Save': 'Save'} 
    5152        response = self.publish(path, self.basic_auth, extra=extra, request_method='GET').getBody() 
    52  
    53         open('/tmp/right.captcha.html','w').write(response) 
    54  
    5553        self.assert_(not NOT_VALID.search(response)) 
    5654 
     
    6664    def testSubmitRightCaptchaTwice(self): 
    6765        hashkey = self.portal.getCaptcha() 
    68         key = getWord(int(parseKey(decrypt(self.captcha_key, hashkey))['key'])) 
     66        key = getWord(int(parseKey(decrypt(self.captcha_key, hashkey))['key'])-1) 
    6967        parameters = 'form.submitted=1&key=%s'%key 
    7068        path = '%s/test_form?%s'%(self.absolute_url, parameters) 
Note: See TracChangeset for help on using the changeset viewer.