OPSI.web2.test.test_cgi module

class OPSI.web2.test.test_cgi.CGI(methodName='runTest')

Bases: OPSI.web2.test.test_cgi.CGITestBase

Test cases for basic twcgi.FilteredScript functionality

testReadEmptyInput()

Test that the CGI can successfully read from an empty input stream

test_CGI()

Test that the given DUMMY_CGI is executed and the expected output returned

test_readAllInput()

Test that we can all input can be read regardless of CONTENT_LENGTH

test_readInput()

Test that we can successfully read an input stream with data

class OPSI.web2.test.test_cgi.CGIDirectoryTest(methodName='runTest')

Bases: OPSI.web2.test.test_cgi.CGITestBase

Test cases for OPSI.web2.twcgi.CGIDirectory

createScript(filename)

Write a dummy cgi script @param filename: a str destination for the cgi

setUp()
test_cantRender()

We do not support directory listing of CGIDirectories So our render method should always return a 403

test_foundScript()

We should get twcgi.CGISCript instances when we locate a CGI

test_notFound()

Correctly handle non-existant children by returning a 404

test_scriptsExecute()

Verify that CGI scripts within a CGIDirectory can actually be executed

test_subDirectory()

When a subdirectory is request we should get another CGIDirectory

class OPSI.web2.test.test_cgi.CGITestBase(methodName='runTest')

Bases: twisted.trial._asynctest.TestCase

Base class for CGI using tests

getPage(request, resource)

Return the body of the given resource for the given request

@param request: A L{SimpleRequest} instance to act on the resource @param resource: A L{IResource} to be rendered @return: A L{Deferred} that fires with the response body returned by

resource for the request
setUpResource(cgi)

Set up the cgi resource to be tested.

@param cgi: A string containing a Python CGI script. @return: A L{PythonScript} instance

class OPSI.web2.test.test_cgi.PythonScript(filename, filters=None)

Bases: OPSI.web2.twcgi.FilteredScript

A specialized FilteredScript that just runs its file in a python interpreter.

filters = ('/tmp/shiningpanda/jobs/ebf74689/virtualenvs/d41d8cd9/bin/python',)
OPSI.web2.test.test_cgi.readStreamToString(s)

Read all data from a stream into a string.

@param s: a L{OPSI.web2.stream.IByteStream} to read from. @return: a L{Deferred} results in a str