Improve docstring examples
This commit improves docstring examples. The original examples are written in interactive mode style. However, I feel it's weird when it is multiple lines, especially. So, this commit just removes '>>> ' and updates some code block attributes. Change-Id: I2f46042607c0f57d93634fbdffbb4400256a8489
This commit is contained in:
parent
9d52e99ef1
commit
683abe2a39
|
@ -72,15 +72,15 @@ def available_modules():
|
||||||
:raise PluginRegistrationException: if a plugin exposes a service_version
|
:raise PluginRegistrationException: if a plugin exposes a service_version
|
||||||
already defined by Tempest or another plugin.
|
already defined by Tempest or another plugin.
|
||||||
|
|
||||||
Examples:
|
Examples::
|
||||||
|
|
||||||
>>> from tempest import config
|
from tempest import config
|
||||||
>>> params = {}
|
params = {}
|
||||||
>>> for service_version in available_modules():
|
for service_version in available_modules():
|
||||||
>>> service = service_version.split('.')[0]
|
service = service_version.split('.')[0]
|
||||||
>>> params[service] = config.service_client_config(service)
|
params[service] = config.service_client_config(service)
|
||||||
>>> service_clients = ServiceClients(creds, identity_uri,
|
service_clients = ServiceClients(creds, identity_uri,
|
||||||
>>> client_parameters=params)
|
client_parameters=params)
|
||||||
"""
|
"""
|
||||||
extra_service_versions = set([])
|
extra_service_versions = set([])
|
||||||
_tempest_modules = set(tempest_modules())
|
_tempest_modules = set(tempest_modules())
|
||||||
|
@ -163,17 +163,17 @@ class ClientsFactory(object):
|
||||||
parameters cannot be deleted.
|
parameters cannot be deleted.
|
||||||
:raise ImportError if the specified module_path cannot be imported
|
:raise ImportError if the specified module_path cannot be imported
|
||||||
|
|
||||||
Example:
|
Example::
|
||||||
|
|
||||||
>>> # Get credentials and an auth_provider
|
# Get credentials and an auth_provider
|
||||||
>>> clients = ClientsFactory(
|
clients = ClientsFactory(
|
||||||
>>> module_path='my_service.my_service_clients',
|
module_path='my_service.my_service_clients',
|
||||||
>>> client_names=['ServiceClient1', 'ServiceClient2'],
|
client_names=['ServiceClient1', 'ServiceClient2'],
|
||||||
>>> auth_provider=auth_provider,
|
auth_provider=auth_provider,
|
||||||
>>> service='my_service',
|
service='my_service',
|
||||||
>>> region='region1')
|
region='region1')
|
||||||
>>> my_api_client = clients.MyApiClient()
|
my_api_client = clients.MyApiClient()
|
||||||
>>> my_api_client_region2 = clients.MyApiClient(region='region2')
|
my_api_client_region2 = clients.MyApiClient(region='region2')
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# Import the module. If it's not importable, the raised exception
|
# Import the module. If it's not importable, the raised exception
|
||||||
|
@ -244,19 +244,19 @@ class ServiceClients(object):
|
||||||
It hides some of the complexity from the authorization and configuration
|
It hides some of the complexity from the authorization and configuration
|
||||||
layers.
|
layers.
|
||||||
|
|
||||||
Examples:
|
Examples::
|
||||||
|
|
||||||
>>> # johndoe is a tempest.lib.auth.Credentials type instance
|
# johndoe is a tempest.lib.auth.Credentials type instance
|
||||||
>>> johndoe_clients = clients.ServiceClients(johndoe, identity_uri)
|
johndoe_clients = clients.ServiceClients(johndoe, identity_uri)
|
||||||
>>>
|
|
||||||
>>> # List servers in default region
|
# List servers in default region
|
||||||
>>> johndoe_servers_client = johndoe_clients.compute.ServersClient()
|
johndoe_servers_client = johndoe_clients.compute.ServersClient()
|
||||||
>>> johndoe_servers = johndoe_servers_client.list_servers()
|
johndoe_servers = johndoe_servers_client.list_servers()
|
||||||
>>>
|
|
||||||
>>> # List servers in Region B
|
# List servers in Region B
|
||||||
>>> johndoe_servers_client_B = johndoe_clients.compute.ServersClient(
|
johndoe_servers_client_B = johndoe_clients.compute.ServersClient(
|
||||||
>>> region='B')
|
region='B')
|
||||||
>>> johndoe_servers = johndoe_servers_client_B.list_servers()
|
johndoe_servers = johndoe_servers_client_B.list_servers()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# NOTE(andreaf) This class does not depend on tempest configuration
|
# NOTE(andreaf) This class does not depend on tempest configuration
|
||||||
|
@ -305,14 +305,14 @@ class ServiceClients(object):
|
||||||
Registry automatically for all service client (Tempest stable ones
|
Registry automatically for all service client (Tempest stable ones
|
||||||
and plugins).
|
and plugins).
|
||||||
|
|
||||||
Examples:
|
Examples::
|
||||||
|
|
||||||
>>> identity_params = config.service_client_config('identity')
|
identity_params = config.service_client_config('identity')
|
||||||
>>> params = {
|
params = {
|
||||||
>>> 'identity': identity_params,
|
'identity': identity_params,
|
||||||
>>> 'compute': {'region': 'region2'}}
|
'compute': {'region': 'region2'}}
|
||||||
>>> manager = lib_manager.Manager(
|
manager = lib_manager.Manager(
|
||||||
>>> my_creds, identity_uri, client_parameters=params)
|
my_creds, identity_uri, client_parameters=params)
|
||||||
|
|
||||||
:param credentials: An instance of `auth.Credentials`
|
:param credentials: An instance of `auth.Credentials`
|
||||||
:param identity_uri: URI of the identity API. This should be a
|
:param identity_uri: URI of the identity API. This should be a
|
||||||
|
@ -328,7 +328,6 @@ class ServiceClients(object):
|
||||||
name, as declared in `service_clients.available_modules()` except
|
name, as declared in `service_clients.available_modules()` except
|
||||||
for the version. Values are dictionaries of parameters that are
|
for the version. Values are dictionaries of parameters that are
|
||||||
going to be passed to all clients in the service client module.
|
going to be passed to all clients in the service client module.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self._registered_services = set([])
|
self._registered_services = set([])
|
||||||
self.credentials = credentials
|
self.credentials = credentials
|
||||||
|
|
|
@ -51,36 +51,37 @@ class TempestPlugin(object):
|
||||||
:param ConfigOpts conf: The conf object that can be used to register
|
:param ConfigOpts conf: The conf object that can be used to register
|
||||||
additional options on.
|
additional options on.
|
||||||
|
|
||||||
Example:
|
Example::
|
||||||
>>> # Config options are defined in a config.py module
|
|
||||||
>>> service_option = cfg.BoolOpt(
|
# Config options are defined in a config.py module
|
||||||
>>> "my_service",
|
service_option = cfg.BoolOpt(
|
||||||
>>> default=True,
|
"my_service",
|
||||||
>>> help="Whether or not my service is available")
|
default=True,
|
||||||
>>>
|
help="Whether or not my service is available")
|
||||||
>>> # Note: as long as the group is listed in get_opt_lists,
|
|
||||||
>>> # it will be possible to access its optins in the plugin code
|
# Note: as long as the group is listed in get_opt_lists,
|
||||||
>>> # via ("-" in the group name are replaces with "_"):
|
# it will be possible to access its optins in the plugin code
|
||||||
>>> # CONF.my_service.<option_name>
|
# via ("-" in the group name are replaces with "_"):
|
||||||
>>> my_service_group = cfg.OptGroup(name="my-service",
|
# CONF.my_service.<option_name>
|
||||||
>>> title="My service options")
|
my_service_group = cfg.OptGroup(name="my-service",
|
||||||
>>>
|
title="My service options")
|
||||||
>>> MyServiceGroup = [<list of options>]
|
|
||||||
>>> # (...) More groups and options...
|
MyServiceGroup = [<list of options>]
|
||||||
>>>
|
# (...) More groups and options...
|
||||||
>>> # Plugin is implemented in a plugin.py module
|
|
||||||
>>> from my_plugin import config as my_config
|
# Plugin is implemented in a plugin.py module
|
||||||
>>>
|
from my_plugin import config as my_config
|
||||||
>>> def register_opts(self, conf):
|
|
||||||
>>> conf.register_opt(my_config.service_option,
|
def register_opts(self, conf):
|
||||||
>>> group='service_available')
|
conf.register_opt(my_config.service_option,
|
||||||
>>> conf.register_group(my_config.my_service_group)
|
group='service_available')
|
||||||
>>> conf.register_opts(my_config.MyService +
|
conf.register_group(my_config.my_service_group)
|
||||||
>>> my_config.my_service_group)
|
conf.register_opts(my_config.MyService +
|
||||||
>>>
|
my_config.my_service_group)
|
||||||
>>> conf.register_group(my_config.my_service_feature_group)
|
|
||||||
>>> conf.register_opts(my_config.MyServiceFeaturesGroup,
|
conf.register_group(my_config.my_service_feature_group)
|
||||||
>>> my_config.my_service_feature_group)
|
conf.register_opts(my_config.MyServiceFeaturesGroup,
|
||||||
|
my_config.my_service_feature_group)
|
||||||
"""
|
"""
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -107,37 +108,41 @@ class TempestPlugin(object):
|
||||||
of `service_clients.ServiceClients.register_service_client_module`.
|
of `service_clients.ServiceClients.register_service_client_module`.
|
||||||
:rtype: list of dictionaries
|
:rtype: list of dictionaries
|
||||||
|
|
||||||
Example:
|
Example implementation with one service client::
|
||||||
|
|
||||||
>>> # Example implementation with one service client
|
def get_service_clients(self):
|
||||||
>>> myservice_config = config.service_client_config('myservice')
|
# Example implementation with one service client
|
||||||
>>> params = {
|
myservice_config = config.service_client_config('myservice')
|
||||||
>>> 'name': 'myservice',
|
params = {
|
||||||
>>> 'service_version': 'myservice',
|
'name': 'myservice',
|
||||||
>>> 'module_path': 'myservice_tempest_tests.services',
|
'service_version': 'myservice',
|
||||||
>>> 'client_names': ['API1Client', 'API2Client'],
|
'module_path': 'myservice_tempest_tests.services',
|
||||||
>>> }
|
'client_names': ['API1Client', 'API2Client'],
|
||||||
>>> params.update(myservice_config)
|
}
|
||||||
>>> return [params]
|
params.update(myservice_config)
|
||||||
|
return [params]
|
||||||
|
|
||||||
>>> # Example implementation with two service clients
|
Example implementation with two service clients::
|
||||||
>>> foo1_config = config.service_client_config('foo')
|
|
||||||
>>> params_foo1 = {
|
def get_service_clients(self):
|
||||||
>>> 'name': 'foo_v1',
|
# Example implementation with two service clients
|
||||||
>>> 'service_version': 'foo.v1',
|
foo1_config = config.service_client_config('foo')
|
||||||
>>> 'module_path': 'bar_tempest_tests.services.foo.v1',
|
params_foo1 = {
|
||||||
>>> 'client_names': ['API1Client', 'API2Client'],
|
'name': 'foo_v1',
|
||||||
>>> }
|
'service_version': 'foo.v1',
|
||||||
>>> params_foo1.update(foo_config)
|
'module_path': 'bar_tempest_tests.services.foo.v1',
|
||||||
>>> foo2_config = config.service_client_config('foo')
|
'client_names': ['API1Client', 'API2Client'],
|
||||||
>>> params_foo2 = {
|
}
|
||||||
>>> 'name': 'foo_v2',
|
params_foo1.update(foo_config)
|
||||||
>>> 'service_version': 'foo.v2',
|
foo2_config = config.service_client_config('foo')
|
||||||
>>> 'module_path': 'bar_tempest_tests.services.foo.v2',
|
params_foo2 = {
|
||||||
>>> 'client_names': ['API1Client', 'API2Client'],
|
'name': 'foo_v2',
|
||||||
>>> }
|
'service_version': 'foo.v2',
|
||||||
>>> params_foo2.update(foo2_config)
|
'module_path': 'bar_tempest_tests.services.foo.v2',
|
||||||
>>> return [params_foo1, params_foo2]
|
'client_names': ['API1Client', 'API2Client'],
|
||||||
|
}
|
||||||
|
params_foo2.update(foo2_config)
|
||||||
|
return [params_foo1, params_foo2]
|
||||||
"""
|
"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue