Exemple #1
0
class PublishErrorsHandlerTestCase(test_utils.BaseTestCase):
    """Tests for log.PublishErrorsHandler"""

    def setUp(self):
        super(PublishErrorsHandlerTestCase, self).setUp()
        self.publiserrorshandler = PublishErrorsHandler(logging.ERROR)

    def test_emit_cfg_log_notifier_in_notifier_drivers(self):
        self.config(
            notification_driver=["openstack.common.notifier.rabbit_notifier", "openstack.common.notifier.log_notifier"]
        )
        self.stub_flg = True

        def fake_notifier(*args, **kwargs):
            self.stub_flg = False

        self.stubs.Set(notifier, "notify", fake_notifier)
        logrecord = logging.LogRecord("name", "WARN", "/tmp", 1, "Message", None, None)
        self.publiserrorshandler.emit(logrecord)
        self.assertTrue(self.stub_flg)
Exemple #2
0
 def setUp(self):
     super(PublishErrorsHandlerTestCase, self).setUp()
     self.publiserrorshandler = PublishErrorsHandler(logging.ERROR)