google.appengine.api.apiproxy_stub_map.APIProxyStubMap

Container of APIProxy stubs for more convenient unittesting.

Inherits From: expected_type

Stubs may be either trivial implementations of APIProxy services (e.g. DatastoreFileStub, UserServiceStub) or "real" implementations.

For unittests, we may want to mix and match real and trivial implementations of services in order to better focus testing on individual service implementations. To achieve this, we allow the client to attach stubs to service names, as well as define a default stub to be used if no specific matching stub is identified.

default_stub optional stub. default_stub will be used whenever no specific matching stub is found.

Methods

CancelApiCalls

View source

GetPostCallHooks

View source

Gets a collection for all precall hooks.

GetPreCallHooks

View source

Gets a collection for all precall hooks.

GetStub

View source

Retrieve the stub registered for the specified service.

Args
service string

Returns
stub

Returns the stub registered for 'service', and returns the default stub if no such stub is found.

MakeSyncCall

View source

The APIProxy entry point.

Args
service string representing which service to call
call string representing which function to call
request protocol buffer for the request
response protocol buffer for the response

Returns
Response protocol buffer or None. Some implementations may return a response protocol buffer instead of modifying response. Caller must use returned value in such cases. If response is modified then returns None.

Raises
apiproxy_errors.Error or a subclass.

RegisterStub

View source

Register the provided stub for the specified service.

Args
service string
stub stub

ReplaceStub

View source

Replace the existing stub for the specified service with a new one.

NOTE: This is a risky operation; external callers should use this with caution.

Args
service string
stub stub

SetDefaultStub

View source