def it_configures_correct_logging(self, mocker, app_server, expected_msg): mocker.patch.dict('app.application.config', { 'APP_SERVER': app_server, 'SQLALCHEMY_DATABASE_URI': 'db://localhost/test_db' }) mock_logger_info = mocker.patch("app.application.logger.info") configure_logging() assert mock_logger_info.called assert mock_logger_info.call_args == call(expected_msg)
def it_exits_from_configure_logging_if_already_configured(self, mocker): mocker.patch.dict('app.application.config', { 'APP_SERVER': 'flask', 'SQLALCHEMY_DATABASE_URI': 'db://localhost/test_db' }) mocker.patch("app.logging.StreamHandler", return_value='logger') mocker.patch('app.application.logger.handlers', ['logger']) mock_handler = mocker.patch("app.application.logger.addHandler") configure_logging() assert not mock_handler.called
hourly_actual.station_code, hourly_actual.weather_date) session.rollback() def main(): """ Makes the appropriate method calls in order to submit asynchronous queries to the Wildfire 1 API to get hourly values for all weather stations. """ try: logger.debug('Retrieving hourly actuals...') bot = HourlyActualsJob() loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) loop.run_until_complete(bot.run_wfwx()) # Exit with 0 - success. sys.exit(os.EX_OK) except Exception as exception: # pylint: disable=broad-except # Exit non 0 - failure. logger.error('Failed to retrieve hourly actuals.', exc_info=exception) rc_message = ':scream: Encountered error retrieving hourly actuals' send_rocketchat_notification(rc_message, exception) sys.exit(os.EX_SOFTWARE) if __name__ == '__main__': configure_logging() main()