Ignore:
Timestamp:
Mar 29, 2010 12:40:45 PM (14 years ago)
Author:
mylan
Message:

#172: update testing widget for possibility to use in other tests

File:
1 edited

Legend:

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

    r1991 r2019  
    77 
    88NOT_VALID = re.compile("Please re\-enter validation code") 
     9IMAGE_PATT = '\s+src="%s(/getCaptchaImage/[0-9a-fA-F]+)"' 
    910 
    1011# patch to use test images and dictionary 
    1112testPatch() 
    1213 
     14def addTestLayer(self): 
     15    # Install test_captcha skin layer 
     16    registerDirectory('tests', GLOBALS) 
     17    skins = self.portal.portal_skins 
     18    addDirectoryViews(skins, 'tests', GLOBALS) 
     19    skinName = skins.getDefaultSkin() 
     20    paths = map(string.strip, skins.getSkinPath(skinName).split(',')) 
     21    paths.insert(paths.index('custom')+1, 'test_captcha') 
     22    skins.addSkinSelection(skinName, ','.join(paths)) 
     23    self._refreshSkinData() 
     24 
     25 
    1326class TestCaptchaWidget(ptc.FunctionalTestCase): 
    14  
    15     def addTestLayer(self): 
    16         # Install test_captcha skin layer 
    17         registerDirectory('tests', GLOBALS) 
    18         skins = self.portal.portal_skins 
    19         addDirectoryViews(skins, 'tests', GLOBALS) 
    20         skinName = skins.getDefaultSkin() 
    21         paths = map(string.strip, skins.getSkinPath(skinName).split(',')) 
    22         paths.insert(paths.index('custom')+1, 'test_captcha') 
    23         skins.addSkinSelection(skinName, ','.join(paths)) 
    24         self._refreshSkinData() 
    2527 
    2628    def afterSetUp(self): 
    2729        self.loginAsPortalOwner() 
    2830        self.addProduct(PRODUCT_NAME) 
    29         self.addTestLayer() 
     31        addTestLayer(self) 
    3032        self.portal.invokeFactory('Document', 'index_html') 
    3133        self.portal['index_html'].allowDiscussion(True) 
     
    3840        path = '%s/test_form' % self.absolute_url 
    3941        response = self.publish(path, self.basic_auth, request_method='GET').getBody() 
    40         patt = re.compile('\s+src="%s(/getCaptchaImage/[0-9a-fA-F]+)"' % self.portal.absolute_url()) 
     42        patt = re.compile(IMAGE_PATT % self.portal.absolute_url()) 
    4143        match_obj = patt.search(response) 
    4244 
Note: See TracChangeset for help on using the changeset viewer.