Пример #1
0
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
Пример #2
0
Файл: app.py Проект: pulp/crane
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
Пример #3
0
    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)
Пример #4
0
    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)
Пример #5
0
    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)
Пример #6
0
    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)
Пример #7
0
    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)