Package omeroweb :: Package webadmin :: Package tests :: Module request_factory :: Class Client
[hide private]
[frames] | no frames]

Class Client

source code


A class that can act as a client for testing purposes.

It allows the user to compose GET and POST requests, and obtain the response that the server gave to those requests. The server Response objects are annotated with the details of the contexts and templates that were rendered during the process of serving the request.

Client objects are stateful - they will retain cookie (and thus session) details for the lifetime of the Client instance.

This is not intended as a replacement for Twill/Selenium or the like - it is here to allow testing against the contexts and templates produced by a view, rather than the HTML rendered to the end-user.

Instance Methods [hide private]
 
__init__(self, enforce_csrf_checks=False, **defaults)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
store_exc_info(self, **kwargs)
Stores exceptions when they are generated by a view.
source code
 
_session(self)
Obtains the current session variables.
source code
 
session(self)
Obtains the current session variables.
source code
 
request(self, **request)
The master request method.
source code
 
get(self, path, data={}, follow=False, **extra)
Requests a response from the server using GET.
source code
 
post(self, path, data={}, content_type=MULTIPART_CONTENT, follow=False, **extra)
Requests a response from the server using POST.
source code
 
head(self, path, data={}, follow=False, **extra)
Request a response from the server using HEAD.
source code
 
options(self, path, data={}, follow=False, **extra)
Request a response from the server using OPTIONS.
source code
 
put(self, path, data={}, content_type=MULTIPART_CONTENT, follow=False, **extra)
Send a resource to the server using PUT.
source code
 
delete(self, path, data={}, follow=False, **extra)
Send a DELETE request to the server.
source code
 
login(self, login, password, server_id=1, secure=True)
Sets the Factory to appear as if it has successfully logged into a site.
source code
 
logout(self)
Removes the authenticated user's cookies and session object.
source code
 
_handle_redirects(self, response, **extra)
Follows any redirects by requesting responses from the server using GET.
source code

Inherited from RequestFactory (private): _base_environ

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, enforce_csrf_checks=False, **defaults)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

request(self, **request)

source code 

The master request method. Composes the environment dictionary and passes to the handler, returning the result of the handler. Assumes defaults for the query environment, which can be overridden using the arguments to the request.

Overrides: RequestFactory.request

get(self, path, data={}, follow=False, **extra)

source code 

Requests a response from the server using GET.

Overrides: RequestFactory.get

post(self, path, data={}, content_type=MULTIPART_CONTENT, follow=False, **extra)

source code 

Requests a response from the server using POST.

Overrides: RequestFactory.post

head(self, path, data={}, follow=False, **extra)

source code 

Request a response from the server using HEAD.

Overrides: RequestFactory.head

options(self, path, data={}, follow=False, **extra)

source code 

Request a response from the server using OPTIONS.

Overrides: RequestFactory.options

put(self, path, data={}, content_type=MULTIPART_CONTENT, follow=False, **extra)

source code 

Send a resource to the server using PUT.

Overrides: RequestFactory.put

delete(self, path, data={}, follow=False, **extra)

source code 

Send a DELETE request to the server.

Overrides: RequestFactory.delete

login(self, login, password, server_id=1, secure=True)

source code 

Sets the Factory to appear as if it has successfully logged into a site.

Returns True if login is possible; False if the provided credentials are incorrect, or the user is inactive, or if the sessions framework is not available.

logout(self)

source code 

Removes the authenticated user's cookies and session object.

Causes the authenticated user to be logged out.