From 98bfdd1d347ed795319bd7b4463133c5c6345a94 Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Thu, 4 Dec 2014 08:28:43 +0100 Subject: [PATCH] rabbit: add some tests when rpc_backend is set This change improves test coverage of the rabbit driver for new value allowed in rpc_backend config option. Change-Id: I52a8a8beb5b0d32647f52bb21abd5f7164dac2df --- tests/drivers/test_impl_rabbit.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/drivers/test_impl_rabbit.py b/tests/drivers/test_impl_rabbit.py index 577711171..57eeadc7d 100644 --- a/tests/drivers/test_impl_rabbit.py +++ b/tests/drivers/test_impl_rabbit.py @@ -55,16 +55,26 @@ class TestDeprecatedRabbitDriverLoad(test_utils.BaseTestCase): class TestRabbitDriverLoad(test_utils.BaseTestCase): - def setUp(self): - super(TestRabbitDriverLoad, self).setUp() - self.messaging_conf.transport_driver = 'rabbit' + scenarios = [ + ('rabbit', dict(transport_driver='rabbit', + url='amqp://guest:guest@localhost:5672//')), + ('kombu', dict(transport_driver='kombu', + url='amqp://guest:guest@localhost:5672//')), + ('rabbit+memory', dict(transport_driver='kombu+memory', + url='memory:///')) + ] @mock.patch('oslo.messaging._drivers.impl_rabbit.Connection.ensure') @mock.patch('oslo.messaging._drivers.impl_rabbit.Connection.reset') def test_driver_load(self, fake_ensure, fake_reset): + self.messaging_conf.transport_driver = self.transport_driver transport = messaging.get_transport(self.conf) self.addCleanup(transport.cleanup) - self.assertIsInstance(transport._driver, rabbit_driver.RabbitDriver) + driver = transport._driver + url = driver._get_connection()._url + + self.assertIsInstance(driver, rabbit_driver.RabbitDriver) + self.assertEqual(self.url, url) class TestRabbitIterconsume(test_utils.BaseTestCase):