Fix fake driver handling of failure replies
The driver reply() method is actually passed a full sys.exc_info() tuple. This was masked in the unit tests because the driver ended up basically doing: raise (ValueError, ValueError, ...) which caused a new ValueError to be instantiated and the test was satisified. However, if an exception type has some required arguments, you'll get a TypeError when this statement attempts to instantiate it with no arguments. Change-Id: I4af9c5084954d7b9c5f02cdae3387d17c206985b
This commit is contained in:
parent
747e1a4099
commit
001d66e6e5
@ -32,6 +32,7 @@ class FakeIncomingMessage(base.IncomingMessage):
|
||||
|
||||
def reply(self, reply=None, failure=None, log_failure=True):
|
||||
if self._reply_q:
|
||||
failure = failure[1] if failure else None
|
||||
self._reply_q.put((reply, failure))
|
||||
|
||||
|
||||
|
@ -279,12 +279,18 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin):
|
||||
|
||||
class TestEndpoint(object):
|
||||
def ping(self, ctxt, arg):
|
||||
raise ValueError
|
||||
raise ValueError(arg)
|
||||
|
||||
server_thread = self._setup_server(transport, TestEndpoint())
|
||||
client = self._setup_client(transport)
|
||||
|
||||
self.assertRaises(ValueError, client.call, {}, 'ping', arg='foo')
|
||||
try:
|
||||
client.call({}, 'ping', arg='foo')
|
||||
except Exception as ex:
|
||||
self.assertIsInstance(ex, ValueError)
|
||||
self.assertEquals(ex[0], 'dsfoo')
|
||||
else:
|
||||
self.assertTrue(False)
|
||||
|
||||
self._stop_server(client, server_thread)
|
||||
|
||||
@ -294,12 +300,18 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin):
|
||||
class TestEndpoint(object):
|
||||
@messaging.expected_exceptions(ValueError)
|
||||
def ping(self, ctxt, arg):
|
||||
raise ValueError
|
||||
raise ValueError(arg)
|
||||
|
||||
server_thread = self._setup_server(transport, TestEndpoint())
|
||||
client = self._setup_client(transport)
|
||||
|
||||
self.assertRaises(ValueError, client.call, {}, 'ping', arg='foo')
|
||||
try:
|
||||
client.call({}, 'ping', arg='foo')
|
||||
except Exception as ex:
|
||||
self.assertIsInstance(ex, ValueError)
|
||||
self.assertEquals(ex[0], 'dsfoo')
|
||||
else:
|
||||
self.assertTrue(False)
|
||||
|
||||
self._stop_server(client, server_thread)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user