l.s.w.s.LaunchpadTestRequest(LaunchpadBrowserRequestMixin, TestRequest, ErrorReportRequest) : class documentation

Part of lp.services.webapp.servers View In Hierarchy

Known subclasses: lp.services.webapp.servers.WebServiceTestRequest

Mock request for use in unit and functional tests.

>>> request = LaunchpadTestRequest(SERVER_URL='http://127.0.0.1/foo/bar')

This class subclasses TestRequest - the standard Mock request object used in unit tests

>>> isinstance(request, TestRequest)
True

It provides LaunchpadLayer and adds a mock INotificationRequest implementation.

>>> lp.layers.LaunchpadLayer.providedBy(request)
True
>>> INotificationRequest.providedBy(request)
True
>>> request.uuid == request.response.uuid
True
>>> request.notifications is request.response.notifications
True

It also provides the form_ng attribute that is available from LaunchpadBrowserRequest.

>>> from zope.interface.verify import verifyObject
>>> verifyObject(IBrowserFormNG, request.form_ng)
True

It also provides the query_string_params dict that is available from LaunchpadBrowserRequest.

>>> request = LaunchpadTestRequest(SERVER_URL='http://127.0.0.1/foo/bar',
...     QUERY_STRING='a=1&b=2&c=3')
>>> request.charsets = ['utf-8']
>>> request.query_string_params == {'a': ['1'], 'b': ['2'], 'c': ['3']}
True

If force_fresh_login_for_testing is set to True, the lp.services.webapp.login.isFreshLogin function will always return True. This is useful in tests where you want to avoid needing a fresh login when exercising views such as PersonGPGView

Method __init__ Undocumented
Method uuid Undocumented
Method notifications See INotificationRequest.
Method stepstogo See IBasicLaunchpadRequest.
Method getNearest See IBasicLaunchpadRequest.
Method setInWSGIEnvironment See IBasicLaunchpadRequest.
Method form_ng See ILaunchpadBrowserApplicationRequest.
Method query_string_params See ILaunchpadBrowserApplicationRequest.
Method setPrincipal See IPublicationRequest.
Method clearSecurityPolicyCache See ILaunchpadBrowserApplicationRequest.
Method _createResponse As per zope.publisher.browser.BrowserRequest._createResponse

Inherited from LaunchpadBrowserRequestMixin:

Method getRootURL See IBasicLaunchpadRequest.
Method is_ajax See IBasicLaunchpadRequest.
Method getURL See IBasicLaunchpadRequest.
def __init__(self, body_instream=None, environ=None, form=None, skin=None, outstream=None, method='GET', force_fresh_login_for_testing=False, **kw):
Undocumented
@property
def uuid(self):
Undocumented
@property
def notifications(self):
See INotificationRequest.
@property
def stepstogo(self):
See IBasicLaunchpadRequest.
def getNearest(self, *some_interfaces):
See IBasicLaunchpadRequest.
def setInWSGIEnvironment(self, key, value):
See IBasicLaunchpadRequest.
def _createResponse(self):
As per zope.publisher.browser.BrowserRequest._createResponse
@property
def form_ng(self):
See ILaunchpadBrowserApplicationRequest.
@property
def query_string_params(self):
See ILaunchpadBrowserApplicationRequest.
def setPrincipal(self, principal):
See IPublicationRequest.
def clearSecurityPolicyCache(self):
See ILaunchpadBrowserApplicationRequest.
API Documentation for Launchpad, generated by pydoctor at 2022-06-16 00:00:12.