r4 - 13 Jul 2007 - 11:01:09 - MimiYinYou are here: OSAF >  Projects Web  >  QualityAssuranceTeam > BroadswordHTTPTest
-- MikealRogers - 18 Jul 2006

Broadsword -- HTTPTest Documentation

Where is HTTPTest

HTTPTest lives in the tools repository under the broadsword project.

svn co svn+ssh://svn.osafoundation.org/svn/tools/broadsword/trunk/modules/HTTPTest.py HTTPTest.py

What is HTTPTest

HTTPTest is the base class for all HTTP related test scripts or test tools.

HTTPTest inherits from TestObject for all it's test framework needs.

What is defined in HTTPTest

Initialization

During initialization HTTPTest sends an OPTIONS request to the HTTP server specified during instantiation. If the request fails the test will fail with a python traceback.

Test classes are to be inherited from HTTPTest. During initialization various member variables are set for the benefit of HTTPTest and test class writers.

        Member Assignments:
        self.headers:    dict -- Base headers 1
        self.jsid:       none -- Initialized for jsid parsing, set to None. 2
        self.connection: dict -- All connection information.3

  • 1 -- A dictionary of base headers, during the course of the test more headers may be added such as auth information.
  • 2 -- HTTPTest includes some plumbing for other test tools, one of which is JSONTest which requires that this be set.
  • 3 -- A dictionary holding all information about the test server that was enabled for this test.

request method

Method to make http requests.

Contains logic for handling cookies and keep-alive.

  • Usage:
        self.headers = self.headerAddAuth("user", "password")
        puticsheaders = self.headerAdd({'Content-Type' : 'text/calendar'})   
        puticspath = self.pathBuilder('/home/cosmo-freebusyTestAccount%s/calendar/put.ics') 
        f = open("files/reports/put/put.ics")
        puticsbody = f.read()
        self.request('PUT', put1icspath, body=put1icsbody, headers=puticsheaders)
        self.checkStatus(201)

headerAdd method

Method to return dict copy of self.headers with header added.

  • Usage:
        self.headers = self.headerAddAuth("user", "password")
        puticsheaders = self.headerAdd({'Content-Type' : 'text/calendar'})   
        puticspath = self.pathBuilder('/home/cosmo-freebusyTestAccount%s/calendar/put.ics') 
        f = open("files/reports/put/put.ics")
        puticsbody = f.read()
        self.request('PUT', put1icspath, body=put1icsbody, headers=puticsheaders)
        self.checkStatus(201)

pathbuilder method

Method to pre-pend self.path to a request path.

  • Usage:
        self.headers = self.headerAddAuth("user", "password")
        puticsheaders = self.headerAdd({'Content-Type' : 'text/calendar'})   
        puticspath = self.pathBuilder('/home/cosmo-freebusyTestAccount%s/calendar/put.ics') 
        f = open("files/reports/put/put.ics")
        puticsbody = f.read()
        self.request('PUT', put1icspath, body=put1icsbody, headers=puticsheaders)
        self.checkStatus(201)

checkStatus method

Method to check current status of last response object returned from self.request and log pass of fail for match.

  • Usage:
        self.headers = self.headerAddAuth("user", "password")
        puticsheaders = self.headerAdd({'Content-Type' : 'text/calendar'})   
        puticspath = self.pathBuilder('/home/cosmo-freebusyTestAccount%s/calendar/put.ics') 
        f = open("files/reports/put/put.ics")
        puticsbody = f.read()
        self.request('PUT', put1icspath, body=put1icsbody, headers=puticsheaders)
        self.checkStatus(201)

verifyListInResponse method

Method to verify list of strings in last response body.

  • Usage
        self.verifyListInResponse(positive=['teststring1','teststring2', negative=['string that should not be in respong'])
Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r4 < r3 < r2 < r1 | More topic actions
 
Open Source Applications Foundation
Except where otherwise noted, this site and its content are licensed by OSAF under an Creative Commons License, Attribution Only 3.0.
See list of page contributors for attributions.