Test Modules

funkload.FunkLoadTestCase – FunkLoadTestCase

FunkLoad test case using Richard Jones’ webunit.

$Id: FunkLoadTestCase.py 24757 2005-08-31 12:22:19Z bdelbosc $

class funkload.FunkLoadTestCase.ConfSectionFinder(testcase)

Convenience class. Lets us access conf sections and attrs by doing MyTestCase().conf.sectionName.attrName

class funkload.FunkLoadTestCase.DummyTestCase(methodName='runTest', options=None)

Testing Funkload TestCase.

test_apache()

Simple apache test.

class funkload.FunkLoadTestCase.FunkLoadTestCase(methodName='runTest', options=None)

Unit test with browser and configuration capabilties.

addHeader(key, value)

Add an http header.

addMetadata(ns='meta', **kw)

Add metadata info.

clearBasicAuth()

Remove basic authentication.

clearContext()

Reset the testcase.

clearHeaders()

Remove all http headers set by addHeader or setUserAgent.

Note that the Referer is also removed.

clearKeyAndCertificateFile()

Clear any key file or certificate file paths set by calls to setKeyAndCertificateFile.

comet(url, consumer, description=None)

Initiate a comet request and process the input in a separate thread. This call is async and return a thread object.

The consumer method takes as parameter an input string, it can close the comet connection by returning 0.

conf_get(section, key, default=[], quiet=False)

Return an entry from the options or configuration file.

conf_getFloat(section, key, default=[], quiet=False)

Return a float from the configuration file.

conf_getInt(section, key, default=[], quiet=False)

Return an integer from the configuration file.

conf_getList(section, key, default=[], quiet=False, separator=None)

Return a list from the configuration file.

debugHeaders(debug_headers=True)

Print request headers.

delHeader(key)

Remove an http header key.

delete(url, description=None, ok_codes=None)

Make an HTTP DELETE request to the specified url.

exists(url, params=None, description='Checking existence')

Try a GET on URL return True if the page exists or False.

get(url, params=None, description=None, ok_codes=None, load_auto_links=True, follow_redirect=True)

Make an HTTP GET request to the specified url with params.

Returns a webunit.webunittest.HTTPResponse object.

getBody()

Return the last response content.

getLastBaseUrl()

Return the base href url.

getLastUrl()

Return the last accessed url taking into account redirection.

head(url, description=None, ok_codes=None)

Make an HTTP HEAD request to the specified url with params.

listHref(url_pattern=None, content_pattern=None)

Return a list of href anchor url present in the last html response.

Filtering href with url pattern or link text pattern.

logd(message)

Debug log.

logdd(message)

Verbose Debug log.

logi(message)

Info log.

method(method, url, params=None, description=None, ok_codes=None, load_auto_links=True)

Generic HTTP request method. Can be used to make MOVE, MKCOL, etc method name HTTP requests.

Returns a webunit.webunittest.HTTPResponse object.

midCycle(cycle, cvus)

Called in the middle of a bench cycle.

options(url, description=None, ok_codes=None)

Make an HTTP OPTIONS request to the specified url.

post(url, params=None, description=None, ok_codes=None, load_auto_links=True, follow_redirect=True)

Make an HTTP POST request to the specified url with params.

Returns a webunit.webunittest.HTTPResponse object.

propfind(url, params=None, depth=None, description=None, ok_codes=None)

Make a DAV PROPFIND request to the specified url with params.

put(url, params=None, description=None, ok_codes=None, load_auto_links=True)

Make an HTTP PUT request to the specified url with params.

setBasicAuth(login, password)

Set HTTP basic authentication for the following requests.

setHeader(key, value)

Add or override an http header.

If value is None, the key is removed.

setKeyAndCertificateFile(keyfile_path, certfile_path)

Set the paths to a key file and a certificate file that will be used by a https (ssl/tls) connection when calling the post or get methods.

keyfile_path : path to a PEM formatted file that contains your private key. certfile_path : path to a PEM formatted certificate chain file.

setOkCodes(ok_codes)

Set ok codes.

setUpBench()

Called before the start of the bench.

Note that you can not initialize your testcase instance with this method, you need to use the setUp method instead.

setUpCycle()

Called on bench mode before a cycle start.

Note that you can not initialize your testcase instance with this method, you need to use the setUp method instead.

setUserAgent(agent)

Set User-Agent http header for the next requests.

If agent is None, the user agent header is removed.

sleep()

Sleeps a random amount of time.

Between the predefined sleep_time_min and sleep_time_max values.

tearDownBench()

Called after a the bench.

tearDownCycle()

Called after a cycle in bench mode.

waitUntilAvailable(url, time_out=20, sleep_time=2)

Wait until url is available.

Try a get on url every sleep_time until server is reached or time is out.

xmlrpc(url_in, method_name, params=None, description=None)

Call an xml rpc method_name on url with params.

xmlrpc_call(url_in, method_name, params=None, description=None)

BBB of xmlrpc, this method will be removed for 1.6.0.

funkload.FunkLoadTestCase.random() → x in the interval [0, 1).

funkload.FunkLoadDocTest – FunkLoadDocTest

FunkLoad doc test

$Id$

class funkload.FunkLoadDocTest.FunkLoadDocTest(debug=False, debug_level=1)

Class to use in doctest.

>>> from FunkLoadDocTest import FunkLoadDocTest
>>> fl = FunkLoadDocTest()
>>> ret = fl.get('http://localhost')
>>> ret.code
200
>>> 'HTML' in ret.body
True
runTest()

FL doctest