![]() |
App Engine Python SDK
v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
|
Public Member Functions | |
def | __init__ |
def | activate |
def | deactivate |
def | setup_env |
def | get_stub |
def | init_app_identity_stub |
def | init_blobstore_stub |
def | init_capability_stub |
def | init_channel_stub |
def | init_datastore_v3_stub |
def | init_files_stub |
def | init_images_stub |
def | init_logservice_stub |
def | init_mail_stub |
def | init_memcache_stub |
def | init_taskqueue_stub |
def | init_urlfetch_stub |
def | init_user_stub |
def | init_xmpp_stub |
def | init_search_stub |
def | init_modules_stub |
def | init_all_stubs |
Class providing APIs to manipulate stubs for testing. This class allows to replace App Engine services with fake stub implementations. These stubs act like the actual APIs but do not invoke the replaced services. In order to use a fake service stub or disable a real service, invoke the corresponding 'init_*_stub' methods of this class.
def google.appengine.ext.testbed.Testbed.activate | ( | self | ) |
Activate the testbed. Invoking this method will also assign default values to environment variables required by App Engine services such as os.environ['APPLICATION_ID']. You can set custom values with setup_env().
def google.appengine.ext.testbed.Testbed.deactivate | ( | self | ) |
Deactivate the testbed. This method will restore the API proxy and environment variables to the state before activate() was called. Raises: NotActivatedError: If called before activate() was called.
def google.appengine.ext.testbed.Testbed.get_stub | ( | self, | |
service_name | |||
) |
Get the stub for a service. Args: service_name: The name of the service. Returns: The stub for 'service_name'. Raises: NotActivatedError: The testbed is not activated. StubNotSupportedError: The service is not supported by testbed. StubNotEnabledError: The service stub has not been enabled.
def google.appengine.ext.testbed.Testbed.init_all_stubs | ( | self, | |
enable = True |
|||
) |
Enable all known testbed stubs. Args: enable: True, if the fake services should be enabled, False if real services should be disabled.
def google.appengine.ext.testbed.Testbed.init_app_identity_stub | ( | self, | |
enable = True |
|||
) |
Enable the app identity stub. Args: enable: True, if the fake service should be enabled, False if real service should be disabled.
def google.appengine.ext.testbed.Testbed.init_blobstore_stub | ( | self, | |
enable = True |
|||
) |
Enable the blobstore stub. Args: enable: True, if the fake service should be enabled, False if real service should be disabled.
def google.appengine.ext.testbed.Testbed.init_capability_stub | ( | self, | |
enable = True |
|||
) |
Enable the capability stub. Args: enable: True, if the fake service should be enabled, False if real service should be disabled.
def google.appengine.ext.testbed.Testbed.init_channel_stub | ( | self, | |
enable = True |
|||
) |
Enable the channel stub. Args: enable: True, if the fake service should be enabled, False if real service should be disabled.
def google.appengine.ext.testbed.Testbed.init_datastore_v3_stub | ( | self, | |
enable = True , |
|||
datastore_file = None , |
|||
use_sqlite = False , |
|||
auto_id_policy = AUTO_ID_POLICY_SEQUENTIAL , |
|||
stub_kw_args | |||
) |
Enable the datastore stub. The 'datastore_file' argument can be the path to an existing datastore file, or None (default) to use an in-memory datastore that is initially empty. If you use the sqlite stub and have 'datastore_file' defined, changes you apply in a test will be written to the file. If you use the default datastore stub, changes are _not_ saved to disk unless you set save_changes=True. Note that you can only access those entities of the datastore file which have the same application ID associated with them as the test run. You can change the application ID for a test with setup_env(). Args: enable: True if the fake service should be enabled, False if real service should be disabled. datastore_file: Filename of a dev_appserver datastore file. use_sqlite: True to use the Sqlite stub, False (default) for file stub. auto_id_policy: How datastore stub assigns auto IDs. Either AUTO_ID_POLICY_SEQUENTIAL or AUTO_ID_POLICY_SCATTERED. stub_kw_args: Keyword arguments passed on to the service stub.
def google.appengine.ext.testbed.Testbed.init_files_stub | ( | self, | |
enable = True |
|||
) |
Enable files api stub. Args: enable: True, if the fake service should be enabled, False if real service should be disabled.
def google.appengine.ext.testbed.Testbed.init_images_stub | ( | self, | |
enable = True , |
|||
stub_kwargs | |||
) |
Enable the images stub. The images service stub is only available in dev_appserver because it uses the PIL library. Args: enable: True, if the fake service should be enabled, False if real service should be disabled. stub_kwargs: Keyword arguments passed on to the service stub.
def google.appengine.ext.testbed.Testbed.init_logservice_stub | ( | self, | |
enable = True |
|||
) |
Enable the log service stub. Args: enable: True, if the fake service should be enabled, False if real service should be disabled. Raises: StubNotSupportedError: The logservice stub is unvailable.
def google.appengine.ext.testbed.Testbed.init_mail_stub | ( | self, | |
enable = True , |
|||
stub_kw_args | |||
) |
Enable the mail stub. The email service stub is only available in dev_appserver because it uses the subprocess module. Args: enable: True, if the fake service should be enabled, False if real service should be disabled. stub_kw_args: Keyword arguments passed on to the service stub.
def google.appengine.ext.testbed.Testbed.init_memcache_stub | ( | self, | |
enable = True |
|||
) |
Enable the memcache stub. Args: enable: True, if the fake service should be enabled, False if real service should be disabled.
def google.appengine.ext.testbed.Testbed.init_modules_stub | ( | self, | |
enable = True |
|||
) |
Enable the modules stub. Args: enable: True, if the fake service should be enabled, False if real service should be disabled.
def google.appengine.ext.testbed.Testbed.init_search_stub | ( | self, | |
enable = True |
|||
) |
Enable the search stub. Args: enable: True, if the fake service should be enabled, False if real service should be disabled.
def google.appengine.ext.testbed.Testbed.init_taskqueue_stub | ( | self, | |
enable = True , |
|||
stub_kw_args | |||
) |
Enable the taskqueue stub. Args: enable: True, if the fake service should be enabled, False if real service should be disabled. stub_kw_args: Keyword arguments passed on to the service stub.
def google.appengine.ext.testbed.Testbed.init_urlfetch_stub | ( | self, | |
enable = True |
|||
) |
Enable the urlfetch stub. The urlfetch service stub uses the urllib module to make requests. Because on appserver urllib also relies the urlfetch infrastructure, using this stub will have no effect. Args: enable: True, if the fake service should be enabled, False if real service should be disabled.
def google.appengine.ext.testbed.Testbed.init_user_stub | ( | self, | |
enable = True , |
|||
stub_kw_args | |||
) |
Enable the users stub. Args: enable: True, if the fake service should be enabled, False if real service should be disabled. stub_kw_args: Keyword arguments passed on to the service stub.
def google.appengine.ext.testbed.Testbed.init_xmpp_stub | ( | self, | |
enable = True |
|||
) |
Enable the xmpp stub. Args: enable: True, if the fake service should be enabled, False if real service should be disabled.
def google.appengine.ext.testbed.Testbed.setup_env | ( | self, | |
overwrite = False , |
|||
kwargs | |||
) |
Set up environment variables. Sets default and custom environment variables. By default, all the items in DEFAULT_ENVIRONMENT will be created without being specified. To set a value other than the default, or to pass a custom environment variable, pass a corresponding keyword argument: testbed_instance.setup_env() # All defaults. testbed_instance.setup_env(auth_domain='custom') # All defaults, overriding # AUTH_DOMAIN. testbed_instance.setup_env(custom='foo') # All defaults, plus a custom # os.environ['CUSTOM'] = 'foo'. To overwrite values set by a previous invocation, pass overwrite=True. This will not result in an OVERWRITE entry in os.environ. Args: overwrite: boolean. Whether to overwrite items with corresponding entries in os.environ. **kwargs: environment variables to set. The name of the argument will be uppercased and used as a key in os.environ.