Refactor GetTransportSadPathTestCase
GetTransportSadPathTestCase did an awful lot of mocking for things that were no longer called. Since we only have one callable now, make use of self.assertRaises. Change-Id: Ie93ff74de84ff4d6cc75a3c89dd9a03fdcba5d35
This commit is contained in:
parent
815e25e55b
commit
95b487ba6b
@ -137,28 +137,11 @@ class GetTransportSadPathTestCase(test_utils.BaseTestCase):
|
|||||||
|
|
||||||
def test_get_transport_sad(self):
|
def test_get_transport_sad(self):
|
||||||
self.config(transport_url=self.transport_url)
|
self.config(transport_url=self.transport_url)
|
||||||
driver.DriverManager = mock.Mock()
|
|
||||||
|
|
||||||
try:
|
|
||||||
invoke_args = [self.conf,
|
|
||||||
oslo_messaging.TransportURL.parse(self.conf,
|
|
||||||
self.url)]
|
|
||||||
invoke_kwds = dict(default_exchange='openstack',
|
|
||||||
allowed_remote_exmods=[])
|
|
||||||
|
|
||||||
driver.DriverManager.side_effect = RuntimeError()
|
|
||||||
oslo_messaging.get_transport(self.conf, url=self.url)
|
|
||||||
driver.DriverManager.assert_called_once_with(
|
|
||||||
'oslo.messaging.drivers', invoke_on_load=True,
|
|
||||||
invoke_args=invoke_args, invoke_kwds=invoke_kwds)
|
|
||||||
except Exception as ex:
|
|
||||||
ex_cls = self.ex.pop('cls')
|
ex_cls = self.ex.pop('cls')
|
||||||
ex_msg_contains = self.ex.pop('msg_contains')
|
ex_msg_contains = self.ex.pop('msg_contains')
|
||||||
|
ex = self.assertRaises(
|
||||||
self.assertIsInstance(ex, oslo_messaging.MessagingException)
|
ex_cls, oslo_messaging.get_transport, self.conf, url=self.url)
|
||||||
self.assertIsInstance(ex, ex_cls)
|
|
||||||
self.assertIn(ex_msg_contains, six.text_type(ex))
|
self.assertIn(ex_msg_contains, six.text_type(ex))
|
||||||
|
|
||||||
for k, v in self.ex.items():
|
for k, v in self.ex.items():
|
||||||
self.assertTrue(hasattr(ex, k))
|
self.assertTrue(hasattr(ex, k))
|
||||||
self.assertEqual(v, str(getattr(ex, k)))
|
self.assertEqual(v, str(getattr(ex, k)))
|
||||||
|
Loading…
Reference in New Issue
Block a user