make sure that using multicall on a call with a single result still functions

This commit is contained in:
termie
2011-05-25 15:42:25 -07:00
parent b3338e3ca5
commit fa547237ae
2 changed files with 31 additions and 2 deletions

View File

@@ -233,10 +233,10 @@ class AdapterConsumer(Consumer):
logging.error('rval! %s', rval)
for x in rval:
msg_reply(msg_id, x, None)
msg_reply(msg_id, None, None)
else:
msg_reply(msg_id, rval, None)
#msg_reply(msg_id, rval, None)
# This final None tells multicall that it is done.
msg_reply(msg_id, None, None)
except Exception as e:
logging.exception('Exception during message handling')
if msg_id:

View File

@@ -49,6 +49,35 @@ class RpcTestCase(test.TestCase):
"args": {"value": value}})
self.assertEqual(value, result)
def test_call_succeed_despite_multiple_returns(self):
"""Get a value through rpc call"""
value = 42
result = rpc.call(self.context, 'test', {"method": "echo_three_times",
"args": {"value": value}})
self.assertEqual(value, result)
def test_call_succeed_despite_multiple_returns_yield(self):
"""Get a value through rpc call"""
value = 42
result = rpc.call(self.context, 'test',
{"method": "echo_three_times_yield",
"args": {"value": value}})
self.assertEqual(value, result)
def test_multicall_succeed_once(self):
"""Get a value through rpc call"""
value = 42
result = rpc.multicall(self.context,
'test',
{"method": "echo",
"args": {"value": value}})
i = 0
for x in result:
if i > 0:
self.fail('should only receive one response')
self.assertEqual(value + i, x)
i += 1
def test_multicall_succeed_three_times(self):
"""Get a value through rpc call"""
value = 42