Rename BaseProxy to Proxy
The base resource class is "Resource" but the base proxy class is "BaseProxy" which makes reading the docs a bit strange. It was originally not really a big real because nothing used Proxy directly. But since we add Proxy instances to the Connection for every service in service-types-authority which are now documented as part of the Connection object, calling them BaseProxy is a bit weird. Keep a BaseProxy object around so we don't break out of tree Proxy objects, but add a deprecation to it so people can update. Shift BaseProxy from the main user docs to the contributor layout docs. Add showing inheritance, as well as docs for OpenStackSDKAdapter. Change-Id: I2778b2a04ad0aed4bb6b217151f41503997db1c6
This commit is contained in:
parent
80716c1442
commit
a99d6f1912
@ -50,16 +50,30 @@ a dictionary keyed with the plural noun in the response.
|
||||
Proxy
|
||||
-----
|
||||
|
||||
Each service implements a ``Proxy`` class, within the
|
||||
Each service implements a ``Proxy`` class based on
|
||||
:class:`~openstack.proxy.Proxy`, within the
|
||||
``openstack/<program_name>/vX/_proxy.py`` module. For example, the v2 compute
|
||||
service's ``Proxy`` exists in ``openstack/compute/v2/_proxy.py``.
|
||||
|
||||
This ``Proxy`` class contains a :class:`~keystoneauth1.adapter.Adapter` and
|
||||
provides a higher-level interface for users to work with via a
|
||||
:class:`~openstack.connection.Connection` instance. Rather than requiring
|
||||
users to maintain their own ``Adapter`` and work with lower-level
|
||||
:class:`~openstack.resource.Resource` objects, the ``Proxy`` interface
|
||||
offers a place to make things easier for the caller.
|
||||
The :class:`~openstack.proxy.Proxy` class is based on
|
||||
:class:`~openstack._adapter.OpenStackSDKAdapter` which is in turn based on
|
||||
:class:`~keystoneauth1.adapter.Adapter`.
|
||||
|
||||
.. autoclass:: openstack.proxy.Proxy
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. autoclass:: openstack._adapter.OpenStackSDKAdapter
|
||||
:members:
|
||||
:inherited-members:
|
||||
:show-inheritance:
|
||||
|
||||
Each service's ``Proxy`` provides a higher-level interface for users to work
|
||||
with via a :class:`~openstack.connection.Connection` instance.
|
||||
|
||||
Rather than requiring users to maintain their own ``Adapter`` and work with
|
||||
lower-level :class:`~openstack.resource.Resource` objects, the ``Proxy``
|
||||
interface offers a place to make things easier for the caller.
|
||||
|
||||
Each ``Proxy`` class implements methods which act on the underlying
|
||||
``Resource`` classes which represent the service. For example::
|
||||
@ -80,8 +94,9 @@ Connection
|
||||
----------
|
||||
|
||||
The :class:`openstack.connection.Connection` class builds atop a
|
||||
:class:`os_client_config.config.CloudRegion` object, and provides a higher
|
||||
level interface constructed of ``Proxy`` objects from each of the services.
|
||||
:class:`openstack.config.cloud_region.CloudRegion` object, and provides a
|
||||
higher level interface constructed of ``Proxy`` objects from each of the
|
||||
services.
|
||||
|
||||
The ``Connection`` class' primary purpose is to act as a high-level interface
|
||||
to this SDK, managing the lower level connecton bits and exposing the
|
||||
|
@ -73,12 +73,9 @@ OpenStack services.
|
||||
connection
|
||||
|
||||
Once you have a *Connection* instance, services are accessed through instances
|
||||
of :class:`~openstack.proxy.BaseProxy` or subclasses of it that exist as
|
||||
of :class:`~openstack.proxy.Proxy` or subclasses of it that exist as
|
||||
attributes on the :class:`~openstack.connection.Connection`.
|
||||
|
||||
.. autoclass:: openstack.proxy.BaseProxy
|
||||
:members:
|
||||
|
||||
.. _service-proxies:
|
||||
|
||||
Service Proxies
|
||||
|
@ -62,9 +62,9 @@ class ConnectionMeta(type):
|
||||
doc = _PROXY_TEMPLATE.format(
|
||||
class_doc_strings=class_doc_strings, **service)
|
||||
else:
|
||||
descriptor_args['proxy_class'] = proxy.BaseProxy
|
||||
descriptor_args['proxy_class'] = proxy.Proxy
|
||||
doc = _DOC_TEMPLATE.format(
|
||||
class_name='~openstack.proxy.BaseProxy', **service)
|
||||
class_name='~openstack.proxy.Proxy', **service)
|
||||
descriptor = desc_class(**descriptor_args)
|
||||
descriptor.__doc__ = doc
|
||||
dct[service_type.replace('-', '_')] = descriptor
|
||||
|
@ -19,7 +19,7 @@ from openstack import proxy
|
||||
from openstack import utils
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
class Proxy(proxy.Proxy):
|
||||
|
||||
def chassis(self, details=False, **query):
|
||||
"""Retrieve a generator of chassis.
|
||||
|
@ -17,7 +17,7 @@ from openstack.block_storage.v2 import volume as _volume
|
||||
from openstack import proxy
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
class Proxy(proxy.Proxy):
|
||||
|
||||
def get_snapshot(self, snapshot):
|
||||
"""Get a single snapshot
|
||||
|
@ -28,7 +28,7 @@ from openstack import resource
|
||||
from openstack import utils
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
class Proxy(proxy.Proxy):
|
||||
|
||||
def get_build_info(self):
|
||||
"""Get build info for service engine and API
|
||||
|
@ -27,7 +27,7 @@ from openstack import proxy
|
||||
from openstack import resource
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
class Proxy(proxy.Proxy):
|
||||
|
||||
def find_extension(self, name_or_id, ignore_missing=True):
|
||||
"""Find a single extension
|
||||
|
@ -329,10 +329,10 @@ class Connection(six.with_metaclass(_meta.ConnectionMeta,
|
||||
def add_service(self, service):
|
||||
"""Add a service to the Connection.
|
||||
|
||||
Attaches an instance of the :class:`~openstack.proxy.BaseProxy`
|
||||
Attaches an instance of the :class:`~openstack.proxy.Proxy`
|
||||
class contained in
|
||||
:class:`~openstack.service_description.ServiceDescription`.
|
||||
The :class:`~openstack.proxy.BaseProxy` will be attached to the
|
||||
The :class:`~openstack.proxy.Proxy` will be attached to the
|
||||
`Connection` by its ``service_type`` and by any ``aliases`` that
|
||||
may be specified.
|
||||
|
||||
@ -343,7 +343,7 @@ class Connection(six.with_metaclass(_meta.ConnectionMeta,
|
||||
:class:`~openstack.service_description.ServiceDescription`
|
||||
will be created.
|
||||
"""
|
||||
# If we don't have a proxy, just instantiate BaseProxy so that
|
||||
# If we don't have a proxy, just instantiate Proxy so that
|
||||
# we get an adapter.
|
||||
if isinstance(service, six.string_types):
|
||||
service = service_description.ServiceDescription(service)
|
||||
|
@ -17,7 +17,7 @@ from openstack.database.v1 import user as _user
|
||||
from openstack import proxy
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
class Proxy(proxy.Proxy):
|
||||
|
||||
def create_database(self, instance, **attrs):
|
||||
"""Create a new database from attributes
|
||||
|
@ -17,7 +17,7 @@ from openstack.identity.v2 import user as _user
|
||||
from openstack import proxy
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
class Proxy(proxy.Proxy):
|
||||
|
||||
def extensions(self):
|
||||
"""Retrieve a generator of extensions
|
||||
|
@ -34,7 +34,7 @@ from openstack.identity.v3 import user as _user
|
||||
from openstack import proxy
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
class Proxy(proxy.Proxy):
|
||||
|
||||
def create_credential(self, **attrs):
|
||||
"""Create a new credential from attributes
|
||||
|
@ -14,7 +14,7 @@ from openstack.image.v1 import image as _image
|
||||
from openstack import proxy
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
class Proxy(proxy.Proxy):
|
||||
|
||||
def upload_image(self, **attrs):
|
||||
"""Upload a new image from attributes
|
||||
|
@ -17,7 +17,7 @@ from openstack import proxy
|
||||
from openstack import resource
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
class Proxy(proxy.Proxy):
|
||||
|
||||
def upload_image(self, container_format=None, disk_format=None,
|
||||
data=None, **attrs):
|
||||
|
@ -16,7 +16,7 @@ from openstack.key_manager.v1 import secret as _secret
|
||||
from openstack import proxy
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
class Proxy(proxy.Proxy):
|
||||
|
||||
def create_container(self, **attrs):
|
||||
"""Create a new container from attributes
|
||||
|
@ -20,7 +20,7 @@ from openstack.load_balancer.v2 import pool as _pool
|
||||
from openstack import proxy
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
class Proxy(proxy.Proxy):
|
||||
|
||||
def create_load_balancer(self, **attrs):
|
||||
"""Create a new load balancer from attributes
|
||||
|
@ -18,7 +18,7 @@ from openstack import proxy
|
||||
from openstack import resource
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
class Proxy(proxy.Proxy):
|
||||
|
||||
def create_queue(self, **attrs):
|
||||
"""Create a new queue from attributes
|
||||
|
@ -52,7 +52,7 @@ from openstack import proxy
|
||||
from openstack import utils
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
class Proxy(proxy.Proxy):
|
||||
|
||||
def create_address_scope(self, **attrs):
|
||||
"""Create a new address scope from attributes
|
||||
|
@ -16,7 +16,7 @@ from openstack.object_store.v1 import obj as _obj
|
||||
from openstack import proxy
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
class Proxy(proxy.Proxy):
|
||||
|
||||
Account = _account.Account
|
||||
Container = _container.Container
|
||||
|
@ -22,7 +22,7 @@ from openstack.orchestration.v1 import template as _template
|
||||
from openstack import proxy
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
class Proxy(proxy.Proxy):
|
||||
|
||||
def create_stack(self, preview=False, **attrs):
|
||||
"""Create a new stack from attributes
|
||||
|
@ -16,7 +16,7 @@ from openstack import resource
|
||||
from openstack import utils
|
||||
|
||||
|
||||
# The _check_resource decorator is used on BaseProxy methods to ensure that
|
||||
# The _check_resource decorator is used on Proxy methods to ensure that
|
||||
# the `actual` argument is in fact the type of the `expected` argument.
|
||||
# It does so under two cases:
|
||||
# 1. When strict=False, if and only if `actual` is a Resource instance,
|
||||
@ -40,7 +40,7 @@ def _check_resource(strict=False):
|
||||
return wrap
|
||||
|
||||
|
||||
class BaseProxy(_adapter.OpenStackSDKAdapter):
|
||||
class Proxy(_adapter.OpenStackSDKAdapter):
|
||||
"""Represents a service."""
|
||||
|
||||
def _get_resource(self, resource_type, value, **attrs):
|
||||
@ -313,3 +313,12 @@ class BaseProxy(_adapter.OpenStackSDKAdapter):
|
||||
to delete failed to occur in wait seconds.
|
||||
"""
|
||||
return resource.wait_for_delete(self, value, interval, wait)
|
||||
|
||||
|
||||
class BaseProxy(Proxy):
|
||||
# Backwards compat wrapper
|
||||
|
||||
@utils.deprecated(deprecated_in="0.11.1", removed_in="1.0",
|
||||
details="Use openstack.proxy.Proxy instead")
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(BaseProxy, self).__init__(*args, **kwargs)
|
||||
|
@ -30,7 +30,7 @@ _service_type_manager = os_service_types.ServiceTypes()
|
||||
class ServiceDescription(object):
|
||||
|
||||
#: Proxy class for this service
|
||||
proxy_class = proxy.BaseProxy
|
||||
proxy_class = proxy.Proxy
|
||||
#: main service_type to use to find this service in the catalog
|
||||
service_type = None
|
||||
#: list of aliases this service might be registered as
|
||||
@ -55,10 +55,10 @@ class ServiceDescription(object):
|
||||
|
||||
:param string service_type:
|
||||
service_type to look for in the keystone catalog
|
||||
:param proxy.BaseProxy proxy_class:
|
||||
subclass of :class:`~openstack.proxy.BaseProxy` implementing
|
||||
:param proxy.Proxy proxy_class:
|
||||
subclass of :class:`~openstack.proxy.Proxy` implementing
|
||||
an interface for this service. Defaults to
|
||||
:class:`~openstack.proxy.BaseProxy` which provides REST operations
|
||||
:class:`~openstack.proxy.Proxy` which provides REST operations
|
||||
but no additional features.
|
||||
:param list aliases:
|
||||
Optional list of aliases, if there is more than one name that might
|
||||
@ -73,9 +73,9 @@ class ServiceDescription(object):
|
||||
self._proxy = None
|
||||
|
||||
def _validate_proxy_class(self):
|
||||
if not issubclass(self.proxy_class, proxy.BaseProxy):
|
||||
if not issubclass(self.proxy_class, proxy.Proxy):
|
||||
raise TypeError(
|
||||
"{module}.{proxy_class} must inherit from BaseProxy".format(
|
||||
"{module}.{proxy_class} must inherit from Proxy".format(
|
||||
module=self.proxy_class.__module__,
|
||||
proxy_class=self.proxy_class.__name__))
|
||||
|
||||
|
@ -115,7 +115,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
self.verify_update(self.proxy.update_cluster, cluster.Cluster)
|
||||
|
||||
@deprecation.fail_if_not_removed
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_find')
|
||||
@mock.patch.object(proxy_base.Proxy, '_find')
|
||||
def test_cluster_add_nodes(self, mock_find):
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_find.return_value = mock_cluster
|
||||
@ -135,7 +135,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
expected_args=[["node1"]])
|
||||
|
||||
@deprecation.fail_if_not_removed
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_find')
|
||||
@mock.patch.object(proxy_base.Proxy, '_find')
|
||||
def test_cluster_del_nodes(self, mock_find):
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_find.return_value = mock_cluster
|
||||
@ -157,7 +157,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
expected_kwargs={"key": "value"})
|
||||
|
||||
@deprecation.fail_if_not_removed
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_find')
|
||||
@mock.patch.object(proxy_base.Proxy, '_find')
|
||||
def test_cluster_replace_nodes(self, mock_find):
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_find.return_value = mock_cluster
|
||||
@ -177,7 +177,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
expected_args=[{"node1": "node2"}])
|
||||
|
||||
@deprecation.fail_if_not_removed
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_find')
|
||||
@mock.patch.object(proxy_base.Proxy, '_find')
|
||||
def test_cluster_scale_out(self, mock_find):
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_find.return_value = mock_cluster
|
||||
@ -197,7 +197,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
expected_args=[5])
|
||||
|
||||
@deprecation.fail_if_not_removed
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_find')
|
||||
@mock.patch.object(proxy_base.Proxy, '_find')
|
||||
def test_cluster_scale_in(self, mock_find):
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_find.return_value = mock_cluster
|
||||
@ -221,7 +221,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
service.Service,
|
||||
paginated=False)
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_find')
|
||||
@mock.patch.object(proxy_base.Proxy, '_find')
|
||||
def test_cluster_resize(self, mock_find):
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_find.return_value = mock_cluster
|
||||
@ -242,7 +242,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
expected_kwargs={'k1': 'v1', 'k2': 'v2'})
|
||||
|
||||
@deprecation.fail_if_not_removed
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_find')
|
||||
@mock.patch.object(proxy_base.Proxy, '_find')
|
||||
def test_cluster_attach_policy(self, mock_find):
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_find.return_value = mock_cluster
|
||||
@ -266,7 +266,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
expected_kwargs={"k1": "v1", 'k2': "v2"})
|
||||
|
||||
@deprecation.fail_if_not_removed
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_find')
|
||||
@mock.patch.object(proxy_base.Proxy, '_find')
|
||||
def test_cluster_detach_policy(self, mock_find):
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_find.return_value = mock_cluster
|
||||
@ -286,7 +286,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
expected_args=["FAKE_POLICY"])
|
||||
|
||||
@deprecation.fail_if_not_removed
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_find')
|
||||
@mock.patch.object(proxy_base.Proxy, '_find')
|
||||
def test_cluster_update_policy(self, mock_find):
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_find.return_value = mock_cluster
|
||||
@ -316,7 +316,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
expected_kwargs={'cluster_id': 'FAKE_ID',
|
||||
'path': 'path.to.attr'})
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
def test_cluster_check(self, mock_get):
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_get.return_value = mock_cluster
|
||||
@ -325,7 +325,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
method_args=["FAKE_CLUSTER"])
|
||||
mock_get.assert_called_once_with(cluster.Cluster, "FAKE_CLUSTER")
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
def test_cluster_recover(self, mock_get):
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_get.return_value = mock_cluster
|
||||
@ -335,7 +335,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
mock_get.assert_called_once_with(cluster.Cluster, "FAKE_CLUSTER")
|
||||
|
||||
@deprecation.fail_if_not_removed
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
def test_cluster_operation(self, mock_get):
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_get.return_value = mock_cluster
|
||||
@ -366,7 +366,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
self.verify_get(self.proxy.get_node, node.Node)
|
||||
|
||||
def test_node_get_with_details(self):
|
||||
self._verify2('openstack.proxy.BaseProxy._get',
|
||||
self._verify2('openstack.proxy.Proxy._get',
|
||||
self.proxy.get_node,
|
||||
method_args=['NODE_ID'],
|
||||
method_kwargs={'details': True},
|
||||
@ -383,7 +383,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
def test_node_update(self):
|
||||
self.verify_update(self.proxy.update_node, node.Node)
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
def test_node_check(self, mock_get):
|
||||
mock_node = node.Node.new(id='FAKE_NODE')
|
||||
mock_get.return_value = mock_node
|
||||
@ -392,7 +392,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
method_args=["FAKE_NODE"])
|
||||
mock_get.assert_called_once_with(node.Node, "FAKE_NODE")
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
def test_node_recover(self, mock_get):
|
||||
mock_node = node.Node.new(id='FAKE_NODE')
|
||||
mock_get.return_value = mock_node
|
||||
@ -401,7 +401,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
method_args=["FAKE_NODE"])
|
||||
mock_get.assert_called_once_with(node.Node, "FAKE_NODE")
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
def test_node_adopt(self, mock_get):
|
||||
mock_node = node.Node.new()
|
||||
mock_get.return_value = mock_node
|
||||
@ -412,7 +412,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
|
||||
mock_get.assert_called_once_with(node.Node, None)
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
def test_node_adopt_preview(self, mock_get):
|
||||
mock_node = node.Node.new()
|
||||
mock_get.return_value = mock_node
|
||||
@ -424,7 +424,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
mock_get.assert_called_once_with(node.Node, None)
|
||||
|
||||
@deprecation.fail_if_not_removed
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
def test_node_operation(self, mock_get):
|
||||
mock_node = node.Node.new(id='FAKE_CLUSTER')
|
||||
mock_get.return_value = mock_node
|
||||
@ -472,7 +472,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
fake_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
|
||||
# ClusterPolicy object as input
|
||||
self._verify2('openstack.proxy.BaseProxy._get',
|
||||
self._verify2('openstack.proxy.Proxy._get',
|
||||
self.proxy.get_cluster_policy,
|
||||
method_args=[fake_policy, "FAKE_CLUSTER"],
|
||||
expected_args=[cluster_policy.ClusterPolicy,
|
||||
@ -481,7 +481,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
expected_result=fake_policy)
|
||||
|
||||
# Policy ID as input
|
||||
self._verify2('openstack.proxy.BaseProxy._get',
|
||||
self._verify2('openstack.proxy.Proxy._get',
|
||||
self.proxy.get_cluster_policy,
|
||||
method_args=["FAKE_POLICY", "FAKE_CLUSTER"],
|
||||
expected_args=[cluster_policy.ClusterPolicy,
|
||||
@ -489,7 +489,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
expected_kwargs={"cluster_id": "FAKE_CLUSTER"})
|
||||
|
||||
# Cluster object as input
|
||||
self._verify2('openstack.proxy.BaseProxy._get',
|
||||
self._verify2('openstack.proxy.Proxy._get',
|
||||
self.proxy.get_cluster_policy,
|
||||
method_args=["FAKE_POLICY", fake_cluster],
|
||||
expected_args=[cluster_policy.ClusterPolicy,
|
||||
|
@ -126,7 +126,7 @@ class TestComputeProxy(test_proxy_base.TestProxyBase):
|
||||
test_interface.server_id = server_id
|
||||
|
||||
# Case1: ServerInterface instance is provided as value
|
||||
self._verify2("openstack.proxy.BaseProxy._delete",
|
||||
self._verify2("openstack.proxy.Proxy._delete",
|
||||
self.proxy.delete_server_interface,
|
||||
method_args=[test_interface],
|
||||
method_kwargs={"server": server_id},
|
||||
@ -136,7 +136,7 @@ class TestComputeProxy(test_proxy_base.TestProxyBase):
|
||||
"ignore_missing": True})
|
||||
|
||||
# Case2: ServerInterface ID is provided as value
|
||||
self._verify2("openstack.proxy.BaseProxy._delete",
|
||||
self._verify2("openstack.proxy.Proxy._delete",
|
||||
self.proxy.delete_server_interface,
|
||||
method_args=[interface_id],
|
||||
method_kwargs={"server": server_id},
|
||||
@ -163,7 +163,7 @@ class TestComputeProxy(test_proxy_base.TestProxyBase):
|
||||
test_interface.server_id = server_id
|
||||
|
||||
# Case1: ServerInterface instance is provided as value
|
||||
self._verify2('openstack.proxy.BaseProxy._get',
|
||||
self._verify2('openstack.proxy.Proxy._get',
|
||||
self.proxy.get_server_interface,
|
||||
method_args=[test_interface],
|
||||
method_kwargs={"server": server_id},
|
||||
@ -172,7 +172,7 @@ class TestComputeProxy(test_proxy_base.TestProxyBase):
|
||||
"server_id": server_id})
|
||||
|
||||
# Case2: ServerInterface ID is provided as value
|
||||
self._verify2('openstack.proxy.BaseProxy._get',
|
||||
self._verify2('openstack.proxy.Proxy._get',
|
||||
self.proxy.get_server_interface,
|
||||
method_args=[interface_id],
|
||||
method_kwargs={"server": server_id},
|
||||
|
@ -41,7 +41,7 @@ class TestDatabaseProxy(test_proxy_base.TestProxyBase):
|
||||
expected_path_args={"instance_id": "test_id"})
|
||||
|
||||
def test_database_find(self):
|
||||
self._verify2('openstack.proxy.BaseProxy._find',
|
||||
self._verify2('openstack.proxy.Proxy._find',
|
||||
self.proxy.find_database,
|
||||
method_args=["db", "instance"],
|
||||
expected_args=[database.Database, "db"],
|
||||
@ -106,7 +106,7 @@ class TestDatabaseProxy(test_proxy_base.TestProxyBase):
|
||||
expected_path_args={"instance_id": "id"})
|
||||
|
||||
def test_user_find(self):
|
||||
self._verify2('openstack.proxy.BaseProxy._find',
|
||||
self._verify2('openstack.proxy.Proxy._find',
|
||||
self.proxy.find_user,
|
||||
method_args=["user", "instance"],
|
||||
expected_args=[user.User, "user"],
|
||||
|
@ -57,7 +57,7 @@ class TestImageProxy(test_proxy_base.TestProxyBase):
|
||||
self.verify_delete(self.proxy.delete_image, image.Image, True)
|
||||
|
||||
@mock.patch("openstack.resource.Resource._translate_response")
|
||||
@mock.patch("openstack.proxy.BaseProxy._get")
|
||||
@mock.patch("openstack.proxy.Proxy._get")
|
||||
@mock.patch("openstack.image.v2.image.Image.update")
|
||||
def test_image_update(self, mock_update_image, mock_get_image,
|
||||
mock_transpose):
|
||||
@ -104,7 +104,7 @@ class TestImageProxy(test_proxy_base.TestProxyBase):
|
||||
expected_kwargs={"image_id": "test_id"})
|
||||
|
||||
def test_member_delete(self):
|
||||
self._verify2("openstack.proxy.BaseProxy._delete",
|
||||
self._verify2("openstack.proxy.Proxy._delete",
|
||||
self.proxy.remove_member,
|
||||
method_args=["member_id"],
|
||||
method_kwargs={"image": "image_id",
|
||||
@ -115,7 +115,7 @@ class TestImageProxy(test_proxy_base.TestProxyBase):
|
||||
"ignore_missing": False})
|
||||
|
||||
def test_member_delete_ignore(self):
|
||||
self._verify2("openstack.proxy.BaseProxy._delete",
|
||||
self._verify2("openstack.proxy.Proxy._delete",
|
||||
self.proxy.remove_member,
|
||||
method_args=["member_id"],
|
||||
method_kwargs={"image": "image_id"},
|
||||
@ -125,7 +125,7 @@ class TestImageProxy(test_proxy_base.TestProxyBase):
|
||||
"ignore_missing": True})
|
||||
|
||||
def test_member_update(self):
|
||||
self._verify2("openstack.proxy.BaseProxy._update",
|
||||
self._verify2("openstack.proxy.Proxy._update",
|
||||
self.proxy.update_member,
|
||||
method_args=['member_id', 'image_id'],
|
||||
expected_args=[member.Member],
|
||||
@ -133,7 +133,7 @@ class TestImageProxy(test_proxy_base.TestProxyBase):
|
||||
'image_id': 'image_id'})
|
||||
|
||||
def test_member_get(self):
|
||||
self._verify2("openstack.proxy.BaseProxy._get",
|
||||
self._verify2("openstack.proxy.Proxy._get",
|
||||
self.proxy.get_member,
|
||||
method_args=['member_id'],
|
||||
method_kwargs={"image": "image_id"},
|
||||
@ -142,7 +142,7 @@ class TestImageProxy(test_proxy_base.TestProxyBase):
|
||||
'image_id': 'image_id'})
|
||||
|
||||
def test_member_find(self):
|
||||
self._verify2("openstack.proxy.BaseProxy._find",
|
||||
self._verify2("openstack.proxy.Proxy._find",
|
||||
self.proxy.find_member,
|
||||
method_args=['member_id'],
|
||||
method_kwargs={"image": "image_id"},
|
||||
|
@ -134,7 +134,7 @@ class TestLoadBalancerProxy(test_proxy_base.TestProxyBase):
|
||||
expected_kwargs={'pool_id': self.POOL_ID})
|
||||
|
||||
def test_member_find(self):
|
||||
self._verify2('openstack.proxy.BaseProxy._find',
|
||||
self._verify2('openstack.proxy.Proxy._find',
|
||||
self.proxy.find_member,
|
||||
method_args=["MEMBER", self.POOL_ID],
|
||||
expected_args=[member.Member, "MEMBER"],
|
||||
@ -142,7 +142,7 @@ class TestLoadBalancerProxy(test_proxy_base.TestProxyBase):
|
||||
"ignore_missing": True})
|
||||
|
||||
def test_member_update(self):
|
||||
self._verify2('openstack.proxy.BaseProxy._update',
|
||||
self._verify2('openstack.proxy.Proxy._update',
|
||||
self.proxy.update_member,
|
||||
method_args=["MEMBER", self.POOL_ID],
|
||||
expected_args=[member.Member, "MEMBER"],
|
||||
@ -225,7 +225,7 @@ class TestLoadBalancerProxy(test_proxy_base.TestProxyBase):
|
||||
expected_kwargs={'l7policy_id': self.L7_POLICY_ID})
|
||||
|
||||
def test_l7_rule_find(self):
|
||||
self._verify2('openstack.proxy.BaseProxy._find',
|
||||
self._verify2('openstack.proxy.Proxy._find',
|
||||
self.proxy.find_l7_rule,
|
||||
method_args=["RULE", self.L7_POLICY_ID],
|
||||
expected_args=[l7_rule.L7Rule, "RULE"],
|
||||
@ -233,7 +233,7 @@ class TestLoadBalancerProxy(test_proxy_base.TestProxyBase):
|
||||
"ignore_missing": True})
|
||||
|
||||
def test_l7_rule_update(self):
|
||||
self._verify2('openstack.proxy.BaseProxy._update',
|
||||
self._verify2('openstack.proxy.Proxy._update',
|
||||
self.proxy.update_l7_rule,
|
||||
method_args=["RULE", self.L7_POLICY_ID],
|
||||
expected_args=[l7_rule.L7Rule, "RULE"],
|
||||
|
@ -46,7 +46,7 @@ class TestMessageProxy(test_proxy_base.TestProxyBase):
|
||||
def test_queue_delete_ignore(self):
|
||||
self.verify_delete(self.proxy.delete_queue, queue.Queue, True)
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
def test_message_post(self, mock_get_resource):
|
||||
message_obj = message.Message(queue_name="test_queue")
|
||||
mock_get_resource.return_value = message_obj
|
||||
@ -57,10 +57,10 @@ class TestMessageProxy(test_proxy_base.TestProxyBase):
|
||||
mock_get_resource.assert_called_once_with(message.Message, None,
|
||||
queue_name="test_queue")
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
def test_message_get(self, mock_get_resource):
|
||||
mock_get_resource.return_value = "resource_or_id"
|
||||
self._verify2("openstack.proxy.BaseProxy._get",
|
||||
self._verify2("openstack.proxy.Proxy._get",
|
||||
self.proxy.get_message,
|
||||
method_args=["test_queue", "resource_or_id"],
|
||||
expected_args=[message.Message, "resource_or_id"])
|
||||
@ -76,12 +76,12 @@ class TestMessageProxy(test_proxy_base.TestProxyBase):
|
||||
paginated=True, method_args=["test_queue"],
|
||||
expected_kwargs={"queue_name": "test_queue"})
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
def test_message_delete(self, mock_get_resource):
|
||||
fake_message = mock.Mock()
|
||||
fake_message.id = "message_id"
|
||||
mock_get_resource.return_value = fake_message
|
||||
self._verify2("openstack.proxy.BaseProxy._delete",
|
||||
self._verify2("openstack.proxy.Proxy._delete",
|
||||
self.proxy.delete_message,
|
||||
method_args=["test_queue", "resource_or_id", None,
|
||||
False],
|
||||
@ -93,12 +93,12 @@ class TestMessageProxy(test_proxy_base.TestProxyBase):
|
||||
"resource_or_id",
|
||||
queue_name="test_queue")
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
def test_message_delete_claimed(self, mock_get_resource):
|
||||
fake_message = mock.Mock()
|
||||
fake_message.id = "message_id"
|
||||
mock_get_resource.return_value = fake_message
|
||||
self._verify2("openstack.proxy.BaseProxy._delete",
|
||||
self._verify2("openstack.proxy.Proxy._delete",
|
||||
self.proxy.delete_message,
|
||||
method_args=["test_queue", "resource_or_id", "claim_id",
|
||||
False],
|
||||
@ -110,12 +110,12 @@ class TestMessageProxy(test_proxy_base.TestProxyBase):
|
||||
"resource_or_id",
|
||||
queue_name="test_queue")
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
def test_message_delete_ignore(self, mock_get_resource):
|
||||
fake_message = mock.Mock()
|
||||
fake_message.id = "message_id"
|
||||
mock_get_resource.return_value = fake_message
|
||||
self._verify2("openstack.proxy.BaseProxy._delete",
|
||||
self._verify2("openstack.proxy.Proxy._delete",
|
||||
self.proxy.delete_message,
|
||||
method_args=["test_queue", "resource_or_id", None,
|
||||
True],
|
||||
@ -132,10 +132,10 @@ class TestMessageProxy(test_proxy_base.TestProxyBase):
|
||||
self.proxy.create_subscription,
|
||||
method_args=["test_queue"])
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
def test_subscription_get(self, mock_get_resource):
|
||||
mock_get_resource.return_value = "resource_or_id"
|
||||
self._verify2("openstack.proxy.BaseProxy._get",
|
||||
self._verify2("openstack.proxy.Proxy._get",
|
||||
self.proxy.get_subscription,
|
||||
method_args=["test_queue", "resource_or_id"],
|
||||
expected_args=[subscription.Subscription,
|
||||
@ -152,7 +152,7 @@ class TestMessageProxy(test_proxy_base.TestProxyBase):
|
||||
paginated=True, method_args=["test_queue"],
|
||||
expected_kwargs={"queue_name": "test_queue"})
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
def test_subscription_delete(self, mock_get_resource):
|
||||
mock_get_resource.return_value = "resource_or_id"
|
||||
self.verify_delete(self.proxy.delete_subscription,
|
||||
@ -162,7 +162,7 @@ class TestMessageProxy(test_proxy_base.TestProxyBase):
|
||||
subscription.Subscription, "resource_or_id",
|
||||
queue_name="test_queue")
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
def test_subscription_delete_ignore(self, mock_get_resource):
|
||||
mock_get_resource.return_value = "resource_or_id"
|
||||
self.verify_delete(self.proxy.delete_subscription,
|
||||
@ -178,7 +178,7 @@ class TestMessageProxy(test_proxy_base.TestProxyBase):
|
||||
method_args=["test_queue"])
|
||||
|
||||
def test_claim_get(self):
|
||||
self._verify2("openstack.proxy.BaseProxy._get",
|
||||
self._verify2("openstack.proxy.Proxy._get",
|
||||
self.proxy.get_claim,
|
||||
method_args=["test_queue", "resource_or_id"],
|
||||
expected_args=[claim.Claim,
|
||||
@ -189,7 +189,7 @@ class TestMessageProxy(test_proxy_base.TestProxyBase):
|
||||
'openstack.message.v2.claim.Claim')
|
||||
|
||||
def test_claim_update(self):
|
||||
self._verify2("openstack.proxy.BaseProxy._update",
|
||||
self._verify2("openstack.proxy.Proxy._update",
|
||||
self.proxy.update_claim,
|
||||
method_args=["test_queue", "resource_or_id"],
|
||||
method_kwargs={"k1": "v1"},
|
||||
|
@ -316,7 +316,7 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
self.verify_find(self.proxy.find_network, network.Network)
|
||||
|
||||
def test_network_find_with_filter(self):
|
||||
self._verify2('openstack.proxy.BaseProxy._find',
|
||||
self._verify2('openstack.proxy.Proxy._find',
|
||||
self.proxy.find_network,
|
||||
method_args=["net1"],
|
||||
method_kwargs={"project_id": "1"},
|
||||
@ -406,7 +406,7 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
{"pool": "test_id"}, {"pool_id": "test_id"})
|
||||
|
||||
def test_pool_member_find(self):
|
||||
self._verify2('openstack.proxy.BaseProxy._find',
|
||||
self._verify2('openstack.proxy.Proxy._find',
|
||||
self.proxy.find_pool_member,
|
||||
method_args=["MEMBER", "POOL"],
|
||||
expected_args=[pool_member.PoolMember, "MEMBER"],
|
||||
@ -414,7 +414,7 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
"ignore_missing": True})
|
||||
|
||||
def test_pool_member_get(self):
|
||||
self._verify2('openstack.proxy.BaseProxy._get',
|
||||
self._verify2('openstack.proxy.Proxy._get',
|
||||
self.proxy.get_pool_member,
|
||||
method_args=["MEMBER", "POOL"],
|
||||
expected_args=[pool_member.PoolMember, "MEMBER"],
|
||||
@ -426,7 +426,7 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
expected_kwargs={"pool_id": "test_id"})
|
||||
|
||||
def test_pool_member_update(self):
|
||||
self._verify2("openstack.proxy.BaseProxy._update",
|
||||
self._verify2("openstack.proxy.Proxy._update",
|
||||
self.proxy.update_pool_member,
|
||||
method_args=["MEMBER", "POOL"],
|
||||
expected_args=[pool_member.PoolMember, "MEMBER"],
|
||||
@ -497,7 +497,7 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
|
||||
def test_qos_bandwidth_limit_rule_find(self):
|
||||
policy = qos_policy.QoSPolicy.new(id=QOS_POLICY_ID)
|
||||
self._verify2('openstack.proxy.BaseProxy._find',
|
||||
self._verify2('openstack.proxy.Proxy._find',
|
||||
self.proxy.find_qos_bandwidth_limit_rule,
|
||||
method_args=['rule_id', policy],
|
||||
expected_args=[
|
||||
@ -523,7 +523,7 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
|
||||
def test_qos_bandwidth_limit_rule_update(self):
|
||||
policy = qos_policy.QoSPolicy.new(id=QOS_POLICY_ID)
|
||||
self._verify2('openstack.proxy.BaseProxy._update',
|
||||
self._verify2('openstack.proxy.Proxy._update',
|
||||
self.proxy.update_qos_bandwidth_limit_rule,
|
||||
method_args=['rule_id', policy],
|
||||
method_kwargs={'foo': 'bar'},
|
||||
@ -556,7 +556,7 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
|
||||
def test_qos_dscp_marking_rule_find(self):
|
||||
policy = qos_policy.QoSPolicy.new(id=QOS_POLICY_ID)
|
||||
self._verify2('openstack.proxy.BaseProxy._find',
|
||||
self._verify2('openstack.proxy.Proxy._find',
|
||||
self.proxy.find_qos_dscp_marking_rule,
|
||||
method_args=['rule_id', policy],
|
||||
expected_args=[qos_dscp_marking_rule.QoSDSCPMarkingRule,
|
||||
@ -581,7 +581,7 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
|
||||
def test_qos_dscp_marking_rule_update(self):
|
||||
policy = qos_policy.QoSPolicy.new(id=QOS_POLICY_ID)
|
||||
self._verify2('openstack.proxy.BaseProxy._update',
|
||||
self._verify2('openstack.proxy.Proxy._update',
|
||||
self.proxy.update_qos_dscp_marking_rule,
|
||||
method_args=['rule_id', policy],
|
||||
method_kwargs={'foo': 'bar'},
|
||||
@ -614,7 +614,7 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
|
||||
def test_qos_minimum_bandwidth_rule_find(self):
|
||||
policy = qos_policy.QoSPolicy.new(id=QOS_POLICY_ID)
|
||||
self._verify2('openstack.proxy.BaseProxy._find',
|
||||
self._verify2('openstack.proxy.Proxy._find',
|
||||
self.proxy.find_qos_minimum_bandwidth_rule,
|
||||
method_args=['rule_id', policy],
|
||||
expected_args=[
|
||||
@ -640,7 +640,7 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
|
||||
def test_qos_minimum_bandwidth_rule_update(self):
|
||||
policy = qos_policy.QoSPolicy.new(id=QOS_POLICY_ID)
|
||||
self._verify2('openstack.proxy.BaseProxy._update',
|
||||
self._verify2('openstack.proxy.Proxy._update',
|
||||
self.proxy.update_qos_minimum_bandwidth_rule,
|
||||
method_args=['rule_id', policy],
|
||||
method_kwargs={'foo': 'bar'},
|
||||
@ -695,11 +695,11 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
def test_quota_get(self):
|
||||
self.verify_get(self.proxy.get_quota, quota.Quota)
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, "_get_resource")
|
||||
@mock.patch.object(proxy_base.Proxy, "_get_resource")
|
||||
def test_quota_get_details(self, mock_get):
|
||||
fake_quota = mock.Mock(project_id='PROJECT')
|
||||
mock_get.return_value = fake_quota
|
||||
self._verify2("openstack.proxy.BaseProxy._get",
|
||||
self._verify2("openstack.proxy.Proxy._get",
|
||||
self.proxy.get_quota,
|
||||
method_args=['QUOTA_ID'],
|
||||
method_kwargs={'details': True},
|
||||
@ -708,11 +708,11 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
'requires_id': False})
|
||||
mock_get.assert_called_once_with(quota.Quota, 'QUOTA_ID')
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, "_get_resource")
|
||||
@mock.patch.object(proxy_base.Proxy, "_get_resource")
|
||||
def test_quota_default_get(self, mock_get):
|
||||
fake_quota = mock.Mock(project_id='PROJECT')
|
||||
mock_get.return_value = fake_quota
|
||||
self._verify2("openstack.proxy.BaseProxy._get",
|
||||
self._verify2("openstack.proxy.Proxy._get",
|
||||
self.proxy.get_quota_default,
|
||||
method_args=['QUOTA_ID'],
|
||||
expected_args=[quota.QuotaDefault],
|
||||
@ -773,7 +773,7 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
def test_router_update(self):
|
||||
self.verify_update(self.proxy.update_router, router.Router)
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
@mock.patch.object(router.Router, 'add_interface')
|
||||
def test_add_interface_to_router_with_port(self, mock_add_interface,
|
||||
mock_get):
|
||||
@ -787,7 +787,7 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
expected_kwargs={"port_id": "PORT"})
|
||||
mock_get.assert_called_once_with(router.Router, "FAKE_ROUTER")
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
@mock.patch.object(router.Router, 'add_interface')
|
||||
def test_add_interface_to_router_with_subnet(self, mock_add_interface,
|
||||
mock_get):
|
||||
@ -801,7 +801,7 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
expected_kwargs={"subnet_id": "SUBNET"})
|
||||
mock_get.assert_called_once_with(router.Router, "FAKE_ROUTER")
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
@mock.patch.object(router.Router, 'remove_interface')
|
||||
def test_remove_interface_from_router_with_port(self, mock_remove,
|
||||
mock_get):
|
||||
@ -815,7 +815,7 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
expected_kwargs={"port_id": "PORT"})
|
||||
mock_get.assert_called_once_with(router.Router, "FAKE_ROUTER")
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
@mock.patch.object(router.Router, 'remove_interface')
|
||||
def test_remove_interface_from_router_with_subnet(self, mock_remove,
|
||||
mock_get):
|
||||
@ -829,7 +829,7 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
expected_kwargs={"subnet_id": "SUBNET"})
|
||||
mock_get.assert_called_once_with(router.Router, "FAKE_ROUTER")
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
@mock.patch.object(router.Router, 'add_gateway')
|
||||
def test_add_gateway_to_router(self, mock_add, mock_get):
|
||||
x_router = router.Router.new(id="ROUTER_ID")
|
||||
@ -842,7 +842,7 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
expected_kwargs={"foo": "bar"})
|
||||
mock_get.assert_called_once_with(router.Router, "FAKE_ROUTER")
|
||||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
@mock.patch.object(router.Router, 'remove_gateway')
|
||||
def test_remove_gateway_from_router(self, mock_remove, mock_get):
|
||||
x_router = router.Router.new(id="ROUTER_ID")
|
||||
|
@ -60,7 +60,7 @@ class TestObjectStoreProxy(test_proxy_base2.TestProxyBase):
|
||||
"container": "name",
|
||||
}
|
||||
|
||||
self._verify2("openstack.proxy.BaseProxy._delete",
|
||||
self._verify2("openstack.proxy.Proxy._delete",
|
||||
self.proxy.delete_object,
|
||||
method_args=["resource"],
|
||||
method_kwargs=expected_kwargs,
|
||||
@ -76,7 +76,7 @@ class TestObjectStoreProxy(test_proxy_base2.TestProxyBase):
|
||||
def test_object_create_attrs(self):
|
||||
kwargs = {"name": "test", "data": "data", "container": "name"}
|
||||
|
||||
self._verify2("openstack.proxy.BaseProxy._create",
|
||||
self._verify2("openstack.proxy.Proxy._create",
|
||||
self.proxy.upload_object,
|
||||
method_kwargs=kwargs,
|
||||
expected_args=[obj.Object],
|
||||
|
@ -87,7 +87,7 @@ class TestOrchestrationProxy(test_proxy_base.TestProxyBase):
|
||||
stk = stack.Stack(id=stack_id, name=stack_name)
|
||||
mock_find.return_value = stk
|
||||
|
||||
self._verify2('openstack.proxy.BaseProxy._get',
|
||||
self._verify2('openstack.proxy.Proxy._get',
|
||||
self.proxy.get_stack_environment,
|
||||
method_args=['IDENTITY'],
|
||||
expected_args=[stack_environment.StackEnvironment],
|
||||
@ -102,7 +102,7 @@ class TestOrchestrationProxy(test_proxy_base.TestProxyBase):
|
||||
stack_name = 'test_stack'
|
||||
stk = stack.Stack(id=stack_id, name=stack_name)
|
||||
|
||||
self._verify2('openstack.proxy.BaseProxy._get',
|
||||
self._verify2('openstack.proxy.Proxy._get',
|
||||
self.proxy.get_stack_environment,
|
||||
method_args=[stk],
|
||||
expected_args=[stack_environment.StackEnvironment],
|
||||
@ -145,7 +145,7 @@ class TestOrchestrationProxy(test_proxy_base.TestProxyBase):
|
||||
stk = stack.Stack(id=stack_id, name=stack_name)
|
||||
mock_find.return_value = stk
|
||||
|
||||
self._verify2('openstack.proxy.BaseProxy._get',
|
||||
self._verify2('openstack.proxy.Proxy._get',
|
||||
self.proxy.get_stack_template,
|
||||
method_args=['IDENTITY'],
|
||||
expected_args=[stack_template.StackTemplate],
|
||||
@ -160,7 +160,7 @@ class TestOrchestrationProxy(test_proxy_base.TestProxyBase):
|
||||
stack_name = 'test_stack'
|
||||
stk = stack.Stack(id=stack_id, name=stack_name)
|
||||
|
||||
self._verify2('openstack.proxy.BaseProxy._get',
|
||||
self._verify2('openstack.proxy.Proxy._get',
|
||||
self.proxy.get_stack_template,
|
||||
method_args=[stk],
|
||||
expected_args=[stack_template.StackTemplate],
|
||||
|
@ -53,7 +53,7 @@ class TestProxyPrivate(testtools.TestCase):
|
||||
self.sot = mock.Mock()
|
||||
self.sot.method = method
|
||||
|
||||
self.fake_proxy = proxy.BaseProxy("session")
|
||||
self.fake_proxy = proxy.Proxy("session")
|
||||
|
||||
def _test_correct(self, value):
|
||||
decorated = proxy._check_resource(strict=False)(self.sot.method)
|
||||
@ -170,7 +170,7 @@ class TestProxyDelete(testtools.TestCase):
|
||||
self.res.id = self.fake_id
|
||||
self.res.delete = mock.Mock()
|
||||
|
||||
self.sot = proxy.BaseProxy(self.session)
|
||||
self.sot = proxy.Proxy(self.session)
|
||||
DeleteableResource.new = mock.Mock(return_value=self.res)
|
||||
|
||||
def test_delete(self):
|
||||
@ -227,7 +227,7 @@ class TestProxyUpdate(testtools.TestCase):
|
||||
self.res = mock.Mock(spec=UpdateableResource)
|
||||
self.res.update = mock.Mock(return_value=self.fake_result)
|
||||
|
||||
self.sot = proxy.BaseProxy(self.session)
|
||||
self.sot = proxy.Proxy(self.session)
|
||||
|
||||
self.attrs = {"x": 1, "y": 2, "z": 3}
|
||||
|
||||
@ -258,7 +258,7 @@ class TestProxyCreate(testtools.TestCase):
|
||||
self.res = mock.Mock(spec=CreateableResource)
|
||||
self.res.create = mock.Mock(return_value=self.fake_result)
|
||||
|
||||
self.sot = proxy.BaseProxy(self.session)
|
||||
self.sot = proxy.Proxy(self.session)
|
||||
|
||||
def test_create_attributes(self):
|
||||
CreateableResource.new = mock.Mock(return_value=self.res)
|
||||
@ -285,7 +285,7 @@ class TestProxyGet(testtools.TestCase):
|
||||
self.res.id = self.fake_id
|
||||
self.res.get = mock.Mock(return_value=self.fake_result)
|
||||
|
||||
self.sot = proxy.BaseProxy(self.session)
|
||||
self.sot = proxy.Proxy(self.session)
|
||||
RetrieveableResource.new = mock.Mock(return_value=self.res)
|
||||
|
||||
def test_get_resource(self):
|
||||
@ -331,7 +331,7 @@ class TestProxyList(testtools.TestCase):
|
||||
self.args = {"a": "A", "b": "B", "c": "C"}
|
||||
self.fake_response = [resource.Resource()]
|
||||
|
||||
self.sot = proxy.BaseProxy(self.session)
|
||||
self.sot = proxy.Proxy(self.session)
|
||||
ListableResource.list = mock.Mock()
|
||||
ListableResource.list.return_value = self.fake_response
|
||||
|
||||
@ -363,7 +363,7 @@ class TestProxyHead(testtools.TestCase):
|
||||
self.res.id = self.fake_id
|
||||
self.res.head = mock.Mock(return_value=self.fake_result)
|
||||
|
||||
self.sot = proxy.BaseProxy(self.session)
|
||||
self.sot = proxy.Proxy(self.session)
|
||||
HeadableResource.new = mock.Mock(return_value=self.res)
|
||||
|
||||
def test_head_resource(self):
|
||||
@ -386,7 +386,7 @@ class TestProxyWaits(testtools.TestCase):
|
||||
super(TestProxyWaits, self).setUp()
|
||||
|
||||
self.session = mock.Mock()
|
||||
self.sot = proxy.BaseProxy(self.session)
|
||||
self.sot = proxy.Proxy(self.session)
|
||||
|
||||
@mock.patch("openstack.resource.wait_for_status")
|
||||
def test_wait_for(self, mock_wait):
|
||||
|
@ -82,7 +82,7 @@ class TestProxyBase(base.TestCase):
|
||||
mocked.assert_called_with(test_method.__self__)
|
||||
|
||||
def verify_create(self, test_method, resource_type,
|
||||
mock_method="openstack.proxy.BaseProxy._create",
|
||||
mock_method="openstack.proxy.Proxy._create",
|
||||
expected_result="result", **kwargs):
|
||||
the_kwargs = {"x": 1, "y": 2, "z": 3}
|
||||
method_kwargs = kwargs.pop("method_kwargs", the_kwargs)
|
||||
@ -100,7 +100,7 @@ class TestProxyBase(base.TestCase):
|
||||
input_path_args=None, expected_path_args=None,
|
||||
method_kwargs=None, expected_args=None,
|
||||
expected_kwargs=None,
|
||||
mock_method="openstack.proxy.BaseProxy._delete"):
|
||||
mock_method="openstack.proxy.Proxy._delete"):
|
||||
method_args = ["resource_or_id"]
|
||||
method_kwargs = method_kwargs or {}
|
||||
method_kwargs["ignore_missing"] = ignore
|
||||
@ -121,7 +121,7 @@ class TestProxyBase(base.TestCase):
|
||||
expected_kwargs=expected_kwargs)
|
||||
|
||||
def verify_get(self, test_method, resource_type, value=None, args=None,
|
||||
mock_method="openstack.proxy.BaseProxy._get",
|
||||
mock_method="openstack.proxy.Proxy._get",
|
||||
ignore_value=False, **kwargs):
|
||||
the_value = value
|
||||
if value is None:
|
||||
@ -149,7 +149,7 @@ class TestProxyBase(base.TestCase):
|
||||
error_message=mock.ANY)
|
||||
|
||||
def verify_head(self, test_method, resource_type,
|
||||
mock_method="openstack.proxy.BaseProxy._head",
|
||||
mock_method="openstack.proxy.Proxy._head",
|
||||
value=None, **kwargs):
|
||||
the_value = [value] if value is not None else []
|
||||
expected_kwargs = {"path_args": kwargs} if kwargs else {}
|
||||
@ -160,7 +160,7 @@ class TestProxyBase(base.TestCase):
|
||||
expected_kwargs=expected_kwargs)
|
||||
|
||||
def verify_find(self, test_method, resource_type, value=None,
|
||||
mock_method="openstack.proxy.BaseProxy._find",
|
||||
mock_method="openstack.proxy.Proxy._find",
|
||||
path_args=None, **kwargs):
|
||||
method_args = value or ["name_or_id"]
|
||||
expected_kwargs = {}
|
||||
@ -187,7 +187,7 @@ class TestProxyBase(base.TestCase):
|
||||
**kwargs)
|
||||
|
||||
def verify_list(self, test_method, resource_type, paginated=False,
|
||||
mock_method="openstack.proxy.BaseProxy._list",
|
||||
mock_method="openstack.proxy.Proxy._list",
|
||||
**kwargs):
|
||||
expected_kwargs = kwargs.pop("expected_kwargs", {})
|
||||
expected_kwargs.update({"paginated": paginated})
|
||||
@ -201,7 +201,7 @@ class TestProxyBase(base.TestCase):
|
||||
|
||||
def verify_list_no_kwargs(self, test_method, resource_type,
|
||||
paginated=False,
|
||||
mock_method="openstack.proxy.BaseProxy._list"):
|
||||
mock_method="openstack.proxy.Proxy._list"):
|
||||
self._verify2(mock_method, test_method,
|
||||
method_kwargs={},
|
||||
expected_args=[resource_type],
|
||||
@ -209,7 +209,7 @@ class TestProxyBase(base.TestCase):
|
||||
expected_result=["result"])
|
||||
|
||||
def verify_update(self, test_method, resource_type, value=None,
|
||||
mock_method="openstack.proxy.BaseProxy._update",
|
||||
mock_method="openstack.proxy.Proxy._update",
|
||||
expected_result="result", path_args=None, **kwargs):
|
||||
method_args = value or ["resource_or_id"]
|
||||
method_kwargs = {"x": 1, "y": 2, "z": 3}
|
||||
|
@ -87,7 +87,7 @@ class TestProxyBase(base.TestCase):
|
||||
mocked.assert_called_with(test_method.__self__)
|
||||
|
||||
def verify_create(self, test_method, resource_type,
|
||||
mock_method="openstack.proxy.BaseProxy._create",
|
||||
mock_method="openstack.proxy.Proxy._create",
|
||||
expected_result="result", **kwargs):
|
||||
the_kwargs = {"x": 1, "y": 2, "z": 3}
|
||||
method_kwargs = kwargs.pop("method_kwargs", the_kwargs)
|
||||
@ -105,7 +105,7 @@ class TestProxyBase(base.TestCase):
|
||||
input_path_args=None, expected_path_args=None,
|
||||
method_kwargs=None, expected_args=None,
|
||||
expected_kwargs=None,
|
||||
mock_method="openstack.proxy.BaseProxy._delete"):
|
||||
mock_method="openstack.proxy.Proxy._delete"):
|
||||
method_args = ["resource_or_id"]
|
||||
method_kwargs = method_kwargs or {}
|
||||
method_kwargs["ignore_missing"] = ignore
|
||||
@ -126,7 +126,7 @@ class TestProxyBase(base.TestCase):
|
||||
expected_kwargs=expected_kwargs)
|
||||
|
||||
def verify_get(self, test_method, resource_type, value=None, args=None,
|
||||
mock_method="openstack.proxy.BaseProxy._get",
|
||||
mock_method="openstack.proxy.Proxy._get",
|
||||
ignore_value=False, **kwargs):
|
||||
the_value = value
|
||||
if value is None:
|
||||
@ -147,7 +147,7 @@ class TestProxyBase(base.TestCase):
|
||||
expected_kwargs=expected_kwargs)
|
||||
|
||||
def verify_head(self, test_method, resource_type,
|
||||
mock_method="openstack.proxy.BaseProxy._head",
|
||||
mock_method="openstack.proxy.Proxy._head",
|
||||
value=None, **kwargs):
|
||||
the_value = [value] if value is not None else []
|
||||
if self.kwargs_to_path_args:
|
||||
@ -161,7 +161,7 @@ class TestProxyBase(base.TestCase):
|
||||
expected_kwargs=expected_kwargs)
|
||||
|
||||
def verify_find(self, test_method, resource_type, value=None,
|
||||
mock_method="openstack.proxy.BaseProxy._find",
|
||||
mock_method="openstack.proxy.Proxy._find",
|
||||
path_args=None, **kwargs):
|
||||
method_args = value or ["name_or_id"]
|
||||
expected_kwargs = {}
|
||||
@ -188,7 +188,7 @@ class TestProxyBase(base.TestCase):
|
||||
**kwargs)
|
||||
|
||||
def verify_list(self, test_method, resource_type, paginated=False,
|
||||
mock_method="openstack.proxy.BaseProxy._list",
|
||||
mock_method="openstack.proxy.Proxy._list",
|
||||
**kwargs):
|
||||
expected_kwargs = kwargs.pop("expected_kwargs", {})
|
||||
expected_kwargs.update({"paginated": paginated})
|
||||
@ -202,7 +202,7 @@ class TestProxyBase(base.TestCase):
|
||||
|
||||
def verify_list_no_kwargs(self, test_method, resource_type,
|
||||
paginated=False,
|
||||
mock_method="openstack.proxy.BaseProxy._list"):
|
||||
mock_method="openstack.proxy.Proxy._list"):
|
||||
self._verify2(mock_method, test_method,
|
||||
method_kwargs={},
|
||||
expected_args=[resource_type],
|
||||
@ -210,7 +210,7 @@ class TestProxyBase(base.TestCase):
|
||||
expected_result=["result"])
|
||||
|
||||
def verify_update(self, test_method, resource_type, value=None,
|
||||
mock_method="openstack.proxy.BaseProxy._update",
|
||||
mock_method="openstack.proxy.Proxy._update",
|
||||
expected_result="result", path_args=None, **kwargs):
|
||||
method_args = value or ["resource_or_id"]
|
||||
method_kwargs = {"x": 1, "y": 2, "z": 3}
|
||||
|
@ -15,7 +15,7 @@ from openstack.workflow.v2 import execution as _execution
|
||||
from openstack.workflow.v2 import workflow as _workflow
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
class Proxy(proxy.Proxy):
|
||||
|
||||
def create_workflow(self, **attrs):
|
||||
"""Create a new workflow from attributes
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
deprecations:
|
||||
- |
|
||||
`openstack.proxy.BaseProxy` has been renamed to `openstack.proxy.Proxy`.
|
||||
A ``BaseProxy`` class remains for easing transition.
|
Loading…
Reference in New Issue
Block a user