def test_capture_exception(self, logger, buffer): with mail.CaptureLogs(logger, buffer): try: 0 / 0 except Exception as error: logger.exception(error) assert 'ERROR:test:division by zero' in buffer.getvalue()
def refresh(): """Update incremental aggregates and materialized views, then email logs to the development team. """ buffer = io.StringIO() with mail.CaptureLogs(manage.logger, buffer): try: manage.update_aggregates() manage.refresh_materialized() download.clear_bucket() except Exception as error: manage.logger.exception(error) try: mail.send_mail(buffer) except Exception as error: logger.exception(error)
def refresh(): """Update incremental aggregates and materialized views, then email logs to the development team. """ buffer = io.StringIO() with mail.CaptureLogs(manage.logger, buffer): try: manage.update_aggregates() manage.refresh_materialized() download.clear_bucket() legal_docs.index_advisory_opinions() legal_docs.load_advisory_opinions_into_s3() # TODO: needs to work with celery # legal_docs.load_current_murs() except Exception as error: manage.logger.exception(error) try: mail.send_mail(buffer) except Exception as error: logger.exception(error)
def test_capture_logs(self, logger, buffer): with mail.CaptureLogs(logger, buffer): logger.info('beep') assert 'INFO:test:beep' in buffer.getvalue()