--
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.
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.
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.
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.
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.
self.verifyListInResponse(positive=['teststring1','teststring2', negative=['string that should not be in respong'])