rpc client test remove rpcapi logic

Remove the test logic which allows overriding the rpcapi, since this
is not used anywhere.  Instead make the rpcapi a test class attribute
so it can be more easily used inside tests.

Change-Id: I21902f46919674093945c84fffda5a8e276f76b5
This commit is contained in:
Steven Hardy 2014-08-18 14:28:28 +01:00
parent 775dc5968d
commit 3dee21c30d
1 changed files with 4 additions and 9 deletions

View File

@ -39,29 +39,24 @@ class EngineRpcAPITestCase(testtools.TestCase):
self.identity = dict(identifier.HeatIdentifier('engine_test_tenant',
'6',
'wordpress'))
self.rpcapi = rpc_client.EngineClient()
super(EngineRpcAPITestCase, self).setUp()
def _test_engine_api(self, method, rpc_method, **kwargs):
ctxt = utils.dummy_context()
if 'rpcapi_class' in kwargs:
rpcapi_class = kwargs['rpcapi_class']
del kwargs['rpcapi_class']
else:
rpcapi_class = rpc_client.EngineClient
rpcapi = rpcapi_class()
expected_retval = 'foo' if method == 'call' else None
kwargs.pop('version', None)
expected_msg = rpcapi.make_msg(method, **kwargs)
expected_msg = self.rpcapi.make_msg(method, **kwargs)
cast_and_call = ['delete_stack']
if rpc_method == 'call' and method in cast_and_call:
kwargs['cast'] = False
with mock.patch.object(rpcapi, rpc_method) as mock_rpc_method:
with mock.patch.object(self.rpcapi, rpc_method) as mock_rpc_method:
mock_rpc_method.return_value = expected_retval
retval = getattr(rpcapi, method)(ctxt, **kwargs)
retval = getattr(self.rpcapi, method)(ctxt, **kwargs)
self.assertEqual(expected_retval, retval)
expected_args = [ctxt, expected_msg, mock.ANY]