def setUp(self):
        super(CeleryTestCase, self).setUp()
        self.celery = celery.Celery(__name__)
        self.celery.conf.CELERY_ALWAYS_EAGER = True

        self.client = InMemoryClient()
        self.handler = SentryCeleryHandler(self.client, ignore_expected=True)
        self.handler.install()
        self.addCleanup(self.handler.uninstall)
Beispiel #2
0
    def test_logging_setup_with_exclusion_list(self):
        app = Flask(__name__)
        raven = InMemoryClient()
        Sentry(app, client=raven, logging=True, logging_exclusions=("excluded_logger",))


        excluded_logger = logging.getLogger("excluded_logger")
        self.assertFalse(excluded_logger.propagate)

        some_other_logger = logging.getLogger("some_other_logger")
        self.assertTrue(some_other_logger.propagate)
Beispiel #3
0
    def test_logging_setup_signal(self):
        app = Flask(__name__)

        mock_handler = Mock()

        def receiver(sender, *args, **kwargs):
            self.assertIn("exclude", kwargs)
            mock_handler(*args, **kwargs)

        logging_configured.connect(receiver)
        raven = InMemoryClient()

        Sentry(
            app, client=raven, logging=True,
            logging_exclusions=("excluded_logger",))

        mock_handler.assert_called()
    def setUp(self):
        super(CeleryLoggingHandlerTestCase, self).setUp()

        self.client = InMemoryClient()

        # register the logger signal
        # and unregister the signal when the test is done
        register_logger_signal(self.client)
        receiver = celery.signals.after_setup_logger.receivers[0][1]
        self.addCleanup(celery.signals.after_setup_logger.disconnect, receiver)

        # remove any existing handlers and restore
        # them when complete
        self.root = logging.getLogger()
        for handler in self.root.handlers:
            self.root.removeHandler(handler)
            self.addCleanup(self.root.addHandler, handler)
Beispiel #5
0
 def bind_sentry(self):
     self.raven = InMemoryClient()
     self.middleware = Sentry(self.app, client=self.raven)
Beispiel #6
0
 def make_client_and_raven(self, logging=False, *args, **kwargs):
     app = create_app(*args, **kwargs)
     raven = InMemoryClient()
     Sentry(app, logging=logging, client=raven)
     return app.test_client(), raven, app