Merge "Set correctly the messaging driver to use in tests"

This commit is contained in:
Jenkins 2014-11-28 17:42:14 +00:00 committed by Gerrit Code Review
commit f58d03e0de
3 changed files with 7 additions and 13 deletions

View File

@ -78,6 +78,7 @@ class TestRabbitTransportURL(test_utils.BaseTestCase):
@mock.patch('oslo.messaging._drivers.impl_rabbit.Connection.ensure')
def test_transport_url(self, fake_ensure):
self.messaging_conf.transport_driver = 'rabbit'
self.messaging_conf.in_memory = False
transport = messaging.get_transport(self.conf, self.url)

View File

@ -51,16 +51,8 @@ class PublishErrorsHandlerTestCase(test_utils.BaseTestCase):
logrecord = logging.LogRecord(name='name', level='ERROR',
pathname='/tmp', lineno=1, msg='Message',
args=None, exc_info=None)
mock_init = mock.Mock(return_value=None)
with mock.patch.object(messaging.notify.notifier.Notifier,
'__init__', mock_init):
# Recreate the handler so the __init__ mock takes effect.
self.publisherrorshandler = (log_handler.
PublishErrorsHandler(logging.ERROR))
self.publisherrorshandler.emit(logrecord)
mock_init.assert_called_with(mock.ANY,
publisher_id='error.publisher')
mock_notify.assert_called_with(None,
'error_notification',
{'error': 'Message'},
'ERROR')
self.publisherrorshandler.emit(logrecord)
self.assertEqual('error.publisher',
self.publisherrorshandler._notifier.publisher_id)
mock_notify.assert_called_with(None, 'error_notification',
{'error': 'Message'}, 'ERROR')

View File

@ -36,6 +36,7 @@ class BaseTestCase(base.BaseTestCase):
from oslo.messaging import conffixture
self.messaging_conf = self.useFixture(conffixture.ConfFixture(conf))
self.messaging_conf.transport_driver = 'fake'
self.conf = self.messaging_conf.conf
moxfixture = self.useFixture(moxstubout.MoxStubout())