Set correctly the messaging driver to use in tests

Depending of the order of the tests executions, the driver can be the
previous configured one. But some tests are written to work on a
specific driver

This change sets the fake driver by default.

It also removes useless mock in test_log_handler.

Change-Id: Ic49bb9aec2e537e55a98315eba8dc97fbb18f96b
This commit is contained in:
Mehdi Abaakouk 2014-11-28 14:32:27 +01:00
parent bd56131b58
commit b369826e42
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())