Browse Source

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
changes/87/137787/4
Mehdi Abaakouk 7 years ago
parent
commit
b369826e42
  1. 1
      tests/drivers/test_impl_rabbit.py
  2. 18
      tests/notify/test_log_handler.py
  3. 1
      tests/utils.py

1
tests/drivers/test_impl_rabbit.py

@ -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)

18
tests/notify/test_log_handler.py

@ -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')

1
tests/utils.py

@ -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())

Loading…
Cancel
Save