Changeset 52553 for funkload/trunk

Show
Ignore:
Timestamp:
02/11/08 22:43:38 (7 months ago)
Author:
bdelbosc
Message:

recorder and test take care of JSF MyFaces? tockens, ready to record/play nuxeo ep, adding content_pattern to listHref

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • funkload/trunk/CHANGES.txt

    r52195 r52553  
    2222:Snapshots: http://funkload.nuxeo.org/snapshots/ 
    2323 
    24 :Target: 1.6.3 
     24:Target: 1.7.0 
     25 
     26New features 
     27~~~~~~~~~~~~ 
     28 
     29* Recorder and test take care of JSF MyFaces tokens which make FunkLoad 
     30  ready to record/play Nuxeo EP or any JBoss Seam application. 
     31 
     32* Change API of listHref to be able to search on link content as well as 
     33  link url. `pattern` parameter is renamed into `url_pattern` and a new 
     34  `content_pattern` can be supply. 
     35 
    2536 
    2637Bug fixes 
  • funkload/trunk/README.txt

    r51931 r52553  
    77:address: bdelbosc _at_ nuxeo.com 
    88 
    9 :version: FunkLoad/1.6.2 
     9:version: FunkLoad/1.7.0 
    1010 
    1111:revision: $Id$ 
     
    112112 
    113113* Easy to install (EasyInstall_) and use, see examples in the demo_ folder. 
     114 
     115* Works fine with CPS or any Zope application, CherryPy, Nuxeo EP or any 
     116  JBoss Seam application ... 
    114117 
    115118 
     
    578581but will failed to record https session. 
    579582 
     583Note that ``fl-record`` will handle automaticly JSF Myfaces token, which 
     584enable to easily record and play any JBoss Seam application. 
     585 
    580586 
    581587The fl-record command 
     
    867873:: 
    868874 
    869   listHref(pattern=None) 
     875  listHref(url_pattern=None, content_pattern=None): 
    870876 
    871877Return a list of href anchor url present in the last html response, 
    872 filtering href using the ``pattern`` regex if present. 
     878filtering href using the ``url_pattern`` regex if present and filtering the 
     879text content of the link with content_pattern if present. 
    873880 
    874881 
  • funkload/trunk/funkload/FunkLoadTestCase.py

    r52283 r52553  
    504504        return '' 
    505505 
    506     def listHref(self, pattern=None): 
     506    def listHref(self, url_pattern=None, content_pattern=None): 
    507507        """Return a list of href anchor url present in the last html response. 
    508508 
    509         Filtering href using the pattern regex if present.""" 
     509        Filtering href with url pattern or link text pattern.""" 
    510510        response = self._response 
    511511        ret = [] 
     
    513513            a_links = response.getDOM().getByName('a') 
    514514            if a_links: 
    515                 ret = [getattr(x, 'href', '') for x in a_links] 
    516             if pattern is not None: 
    517                 pat = re.compile(pattern) 
    518                 ret = [href for href in ret if pat.search(href) is not None] 
    519         return ret 
     515                for link in a_links: 
     516                    try: 
     517                        ret.append((link.getContentString(), link.href)) 
     518                    except AttributeError: 
     519                        pass 
     520            if url_pattern is not None: 
     521                pat = re.compile(url_pattern) 
     522                ret = [link for link in ret 
     523                       if pat.search(link[1]) is not None] 
     524            if content_pattern is not None: 
     525                pat = re.compile(content_pattern) 
     526                ret = [link for link in ret 
     527                       if link[0] and (pat.search(link[0]) is not None)] 
     528        return [link[1] for link in ret] 
    520529 
    521530    def getLastBaseUrl(self): 
  • funkload/trunk/funkload/Recorder.py

    r52195 r52553  
    140140class RecorderProgram: 
    141141    """A tcpwatch to funkload recorder.""" 
     142    MYFACES_STATE = 'org.apache.myfaces.trinidad.faces.STATE' 
     143    MYFACES_FORM = 'org.apache.myfaces.trinidad.faces.FORM' 
    142144    USAGE = """%prog [options] [test_name] 
    143145 
     
    174176        self.script_path = None 
    175177        self.configuration_path = None 
     178        self.use_myfaces = False 
    176179        self.parseArgs(argv) 
    177180 
     
    280283        else: 
    281284            text.append('self.%s(server_url + "%s"' % ( 
    282                 request.method.lower(),  request.rurl)) 
     285                request.method.lower(),  request.rurl.strip())) 
    283286        description = "%s %s" % (request.method.capitalize(), 
    284287                                 request.path | truncate(42)) 
    285288        if request.body: 
    286             params = ('params=%s' % request.extractParam()) 
     289            params = request.extractParam() 
     290            myfaces_form = None 
     291            if self.MYFACES_STATE not in [key for key, value in params]: 
     292                params = 'params=%s' % params 
     293            else: 
     294                # apache myfaces state add a wrapper 
     295                self.use_myfaces = True 
     296                new_params = [] 
     297                for key, value in params: 
     298                    if key == self.MYFACES_STATE: 
     299                        continue 
     300                    if key == self.MYFACES_FORM: 
     301                        myfaces_form = value 
     302                        continue 
     303                    new_params.append([key, value]) 
     304                params = "    self.myfacesParams(%s, form='%s')" % (new_params, 
     305                                                                    myfaces_form) 
    287306            params = re.sub("'Upload\(([^\)]*)\)'", "Upload(\\1)", params) 
    288307            text.append(', ' + params) 
     
    306325        trace('Creating script: %s.\n' % self.script_path) 
    307326        from pkg_resources import resource_string 
    308         tpl = resource_string('funkload', 'data/ScriptTestCase.tpl') 
     327        if self.use_myfaces: 
     328            tpl_name = 'data/MyFacesScriptTestCase.tpl' 
     329        else: 
     330            tpl_name = 'data/ScriptTestCase.tpl' 
     331        tpl = resource_string('funkload', tpl_name) 
    309332        content = tpl % {'script': script, 
    310333                         'test_name': self.test_name,