def test_emit_notification(self, mock_notify):
     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')
 def setUp(self):
     super(PublishErrorsHandlerTestCase, self).setUp()
     self.publisherrorshandler = (log_handler.PublishErrorsHandler(
         logging.ERROR))