def create_app(): """ Creates the flask app, loading blueprints and the configuration. :return: flask app :rtype: Flask """ init_logging() app = Flask(__name__) app.register_blueprint(v1.section) app.register_blueprint(v2.section) app.register_blueprint(crane.section) app.register_error_handler(exceptions.HTTPError, app_util.http_error_handler) config.load(app) # in case the config says that debug mode is on, we need to adjust the # log level set_log_level(app) data.start_monitoring_data_dir(app) search.load_config(app) logging.getLogger(__name__).info('application initialized') return app
def create_app(): """ Creates the flask app, loading blueprints and the configuration. :return: flask app :rtype: Flask """ init_logging() app = CraneFlask(__name__) app.register_blueprint(v1.section) app.register_blueprint(v2.section) app.register_blueprint(crane.section) app.register_error_handler(exceptions.HTTPError, app_util.http_error_handler) config.load(app) # in case the config says that debug mode is on, we need to adjust the # log level set_log_level(app) data.start_monitoring_data_dir(app) search.load_config(app) logging.getLogger(__name__).info('application initialized') return app
def test_monitoring_initialization(self, mock_thread, mock_time): mock_time.return_value = time.time() mock_app = mock.Mock() data.start_monitoring_data_dir(mock_app) mock_thread.assert_called_once_with(target=data.monitor_data_dir, args=(mock_app, mock_time.return_value)) created_thread = mock_thread.return_value created_thread.setDaemon.assert_called_once_with(True) self.assertTrue(created_thread.start.called)