View source on GitHub |
Container of APIProxy stubs for more convenient unittesting.
Inherits From: expected_type
google.appengine.api.apiproxy_stub_map.APIProxyStubMap(
default_stub=None
)
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.
Args | |
---|---|
default_stub
|
optional stub. default_stub will be used whenever no
specific matching stub is found.
|
Methods
CancelApiCalls
CancelApiCalls()
GetPostCallHooks
GetPostCallHooks()
Gets a collection for all precall hooks.
GetPreCallHooks
GetPreCallHooks()
Gets a collection for all precall hooks.
GetStub
GetStub(
service
)
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
MakeSyncCall(
service, call, request, response
)
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
RegisterStub(
service, stub
)
Register the provided stub for the specified service.
Args | |
---|---|
service
|
string |
stub
|
stub |
ReplaceStub
ReplaceStub(
service, stub
)
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
SetDefaultStub(
stub
)