Merge "Remove some useless methods in rpc client"

This commit is contained in:
Jenkins 2016-02-18 05:52:44 +00:00 committed by Gerrit Code Review
commit 3ab53b2f3b
2 changed files with 2 additions and 51 deletions

View File

@ -51,24 +51,6 @@ class EngineClient(object):
client = self._client
return client.cast(ctxt, method, **kwargs)
def local_error_name(self, error):
'''Returns the name of the error with any _Remote postfix removed.
:param error: Remote raised error to derive the name from.
'''
error_name = error.__class__.__name__
return error_name.split('_Remote')[0]
def ignore_error_named(self, error, name):
'''Raises the error unless its local name matches the supplied name
:param error: Remote raised error to derive the local name from.
:param name: Name to compare local name to.
'''
if self.local_error_name(error) != name:
raise error
def profile_type_list(self, ctxt):
return self.call(ctxt, self.make_msg('profile_type_list'))

View File

@ -10,16 +10,12 @@
# License for the specific language governing permissions and limitations
# under the License.
'''
"""
Unit Tests for senlin.rpc.client
'''
"""
import copy
import mock
from oslo_messaging._drivers import common as rpc_common
from senlin.common import exception
from senlin.common import messaging
from senlin.rpc import client as rpc_client
from senlin.tests.unit.common import base
@ -89,33 +85,6 @@ class EngineRpcAPITestCase(base.SenlinTestCase):
key='value')
self.assertEqual(res, new_client.cast.return_value)
def _to_remote_error(self, error):
'''Converts the given exception to one with the _Remote suffix.'''
exc_info = (type(error), error, None)
serialized = rpc_common.serialize_remote_exception(exc_info)
remote_error = rpc_common.deserialize_remote_exception(
serialized, ["senlin.common.exception"])
return remote_error
def test_local_error_name(self):
ex = exception.NodeNotFound(node='A')
self.assertEqual('NodeNotFound', self.rpcapi.local_error_name(ex))
exr = self._to_remote_error(ex)
self.assertEqual('NodeNotFound_Remote', exr.__class__.__name__)
self.assertEqual('NodeNotFound', self.rpcapi.local_error_name(exr))
def test_ignore_error_named(self):
ex = exception.NodeNotFound(node='A')
exr = self._to_remote_error(ex)
self.rpcapi.ignore_error_named(ex, 'NodeNotFound')
self.rpcapi.ignore_error_named(exr, 'NodeNotFound')
self.assertRaises(exception.NodeNotFound,
self.rpcapi.ignore_error_named, ex, 'NotSupported')
self.assertRaises(exception.NodeNotFound,
self.rpcapi.ignore_error_named, exr, 'NotSupported')
def _test_engine_api(self, method, rpc_method, **kwargs):
ctxt = utils.dummy_context()
expected_retval = 'foo' if method == 'call' else None