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_gsa(self): mock_app = mock.MagicMock() fake_url = 'http://pulpproject.org/search' mock_app.config = { config.SECTION_GSA: {config.KEY_URL: fake_url}, } search.load_config(mock_app) self.assertIsInstance(search.backend, GSA) self.assertEqual(search.backend.url, fake_url)
def test_default(self): mock_app = mock.MagicMock() mock_app.config = {} search.load_config(mock_app) # make sure the default backend is used when no settings are present # in the config self.assertIsInstance(search.backend, SearchBackend) # make sure it is not a subclass of SearchBackend self.assertIs(inspect.getmro(search.backend.__class__)[0], SearchBackend)
def test_solr(self): mock_app = mock.MagicMock() fake_url = 'http://pulpproject.org/search' mock_app.config = { config.SECTION_SOLR: {config.KEY_URL: fake_url}, } search.load_config(mock_app) self.assertIsInstance(search.backend, Solr) self.assertEqual(search.backend.url_template, fake_url)