OPSI.web2.test.test_server module¶
A test harness for the OPSI.web2 server.
-
class
OPSI.web2.test.test_server.
AdaptionTestCase
(methodName='runTest')¶ Bases:
twisted.trial._asynctest.TestCase
Test the adaption of various objects to IResource.
Necessary due to the special implementation of __call__ on IResource which extends the behavior provided by the base Interface.__call__.
-
test_oldResources
()¶ Test that providers of L{IOldNevowResource} can be adapted to IResource automatically.
-
test_redundant
()¶ Test that the adaption to IResource of an object which provides IResource returns the same object.
-
test_registered
()¶ Test that if an adapter exists which can provide IResource for an object which does not provide it, that adapter is used.
-
test_transitive
()¶ Test that a special-case transitive adaption from something to IOldNevowResource to IResource is possible.
-
test_unadaptable
()¶ Test that attempting to adapt to IResource an object not adaptable to IResource raises an exception or returns the specified alternate object.
-
-
class
OPSI.web2.test.test_server.
BaseCase
(methodName='runTest')¶ Bases:
twisted.trial._asynctest.TestCase
Base class for test cases that involve testing the result of arbitrary HTTP(S) queries.
-
assertResponse
(request_data, expected_response, failure=False)¶ @type request_data: C{tuple} @type expected_response: C{tuple} @param request_data: A tuple of arguments to pass to L{getResponseFor}:
(root, uri, headers, method, version, prepath). Root resource and requested URI are required, and everything else is optional.- @param expected_response: A 3-tuple of the expected response:
- (responseCode, headers, htmlData)
-
chanrequest
(root, uri, length, headers, method, version, prepath, content)¶
-
getResponseFor
(root, uri, headers={}, method=None, version=None, prepath='', content=None, length=<object object>)¶
-
method
= 'GET'¶
-
version
= (1, 1)¶
-
wait_timeout
= 5.0¶
-
-
class
OPSI.web2.test.test_server.
BaseTestResource
(children=[])¶ Bases:
OPSI.web2.resource.Resource
-
addSlash
= False¶
-
render
(req)¶
-
responseCode
= 200¶
-
responseHeaders
= {}¶
-
responseStream
()¶
-
responseText
= 'This is a fake resource.'¶
-
-
class
OPSI.web2.test.test_server.
EmptyResource
(test)¶ Bases:
OPSI.web2.resource.Resource
-
render
(request)¶
-
-
class
OPSI.web2.test.test_server.
NotOldResource
¶ Bases:
object
Class which does not implement IOldNevowResource or IResource.
Used as an adaptee by L{AdaptionTestCase.test_transitive} to test that if an object which does not provide IResource or IOldNevowResource is adapted to IResource and there is an adapter to IOldNevowResource registered, first that adapter is used, then the included adapter from IOldNevowResource to IResource is used.
-
class
OPSI.web2.test.test_server.
NotResource
¶ Bases:
object
Class which does not implement IResource.
Used as an adaptee by L{AdaptionTestCase.test_registered} to test that if an object which does not provide IResource is adapted to IResource and there is an adapter to IResource registered, that adapter is used.
-
class
OPSI.web2.test.test_server.
OldResourceAdapter
(original)¶ Bases:
object
Adapter to IOldNevowResource.
Registered as an adapter from NotOldResource to IOldNevowResource so that L{AdaptionTestCase.test_transitive} can test that such an adapter will be used to allow the initial input to be adapted to IResource.
-
class
OPSI.web2.test.test_server.
RedirectResourceTest
(methodName='runTest')¶ Bases:
OPSI.web2.test.test_server.BaseCase
-
static
html
(url)¶
-
test_hostRedirect
()¶
-
test_noRedirect
()¶
-
test_pathRedirect
()¶
-
static
-
class
OPSI.web2.test.test_server.
RememberURIs
(methodName='runTest')¶ Bases:
OPSI.web2.test.test_server.BaseCase
Tests for URI memory and lookup mechanism in server.Request.
-
test_deferredLocateChild
()¶ Test deferred value from locateChild()
-
test_locateChildResource
()¶ Test urlForResource() on deeply nested resource looked up via locateChildResource().
-
test_locateResource
()¶ Test urlForResource() on resource looked up via a locateResource() call.
-
test_requestedResource
()¶ Test urlForResource() on deeply nested resource looked up via request processing.
-
test_unknownResource
()¶ Test urlForResource() on unknown resource.
-
test_urlEncoding
()¶ Test to make sure that URL encoding is working.
-
-
class
OPSI.web2.test.test_server.
ResourceAdapter
(original)¶ Bases:
object
Adapter to IResource.
Registered as an adapter from NotResource to IResource so that L{AdaptionTestCase.test_registered} can test that such an adapter will be used.
-
class
OPSI.web2.test.test_server.
SampleWebTest
(methodName='runTest')¶ Bases:
OPSI.web2.test.test_server.BaseCase
-
class
SampleTestResource
(children=[])¶ Bases:
OPSI.web2.test.test_server.BaseTestResource
-
addSlash
= True¶
-
child_missingChild
(req)¶
-
child_remoteAddr
(req)¶
-
child_validChild
(req)¶
-
-
SampleWebTest.
setUp
()¶
-
SampleWebTest.
test_invalidChild
()¶
-
SampleWebTest.
test_leafresource
()¶
-
SampleWebTest.
test_redirectResource
()¶
-
SampleWebTest.
test_remoteAddrExposure
()¶
-
SampleWebTest.
test_root
()¶
-
SampleWebTest.
test_validChild
()¶
-
class
-
class
OPSI.web2.test.test_server.
SimpleRequest
(site, method, uri, headers=None, content=None)¶ Bases:
OPSI.web2.server.Request
I can be used in cases where a Request object is necessary but it is benificial to bypass the chanRequest
-
clientproto
= (1, 1)¶
-
writeResponse
(response)¶
-
-
class
OPSI.web2.test.test_server.
TestChanRequest
(site, method, prepath, uri, length=None, headers=None, version=(1, 1), content=None)¶ -
abortConnection
()¶
-
finish
(failed=False)¶
-
getHostInfo
()¶
-
getRemoteHost
()¶
-
hostInfo
= (IPv4Address(TCP, 'host', 80), False)¶
-
registerProducer
(producer, streaming)¶
-
remoteHost
= IPv4Address(TCP, 'remotehost', 34567)¶
-
unregisterProducer
()¶
-
write
(data)¶
-
writeHeaders
(code, headers)¶
-
writeIntermediateResponse
(code, headers=None)¶
-
-
class
OPSI.web2.test.test_server.
TestDeferredRendering
(methodName='runTest')¶ Bases:
OPSI.web2.test.test_server.BaseCase
-
class
ResourceWithDeferreds
(children=[])¶ Bases:
OPSI.web2.test.test_server.BaseTestResource
-
addSlash
= True¶
-
child_deferred
(req)¶
-
render
(req)¶
-
responseText
= 'I should be wrapped in a Deferred.'¶
-
-
TestDeferredRendering.
test_deferredChild
()¶
-
TestDeferredRendering.
test_deferredRootResource
()¶
-
class
-
class
OPSI.web2.test.test_server.
URLParsingTest
(methodName='runTest')¶ Bases:
OPSI.web2.test.test_server.BaseCase
-
class
TestResource
¶ Bases:
OPSI.web2.resource.LeafResource
-
render
(req)¶
-
-
URLParsingTest.
setUp
()¶
-
URLParsingTest.
test_fullurl
()¶
-
URLParsingTest.
test_normal
()¶
-
URLParsingTest.
test_strangepath
()¶
-
URLParsingTest.
test_strangepathfull
()¶
-
class