def test_get_context(self): server_parameters = mock.Mock(security_key=None, app_class='thumbor.app.ThumborServiceApp') conf = Config(SECURITY_KEY='test') importer = get_importer(conf) context = get_context(server_parameters, conf, importer) expect(context).not_to_be_null()
def test_get_application(self): server_parameters = mock.Mock( security_key=None, app_class="thumbor.app.ThumborServiceApp") conf = Config(SECURITY_KEY="test") importer = get_importer(conf) context = get_context(server_parameters, conf, importer) app = get_application(context) expect(app).not_to_be_null() expect(app).to_be_instance_of(ThumborServiceApp)
def test_can_import_with_custom_error_handler_class(self): conf = Config( USE_CUSTOM_ERROR_HANDLING=True, ERROR_HANDLER_MODULE='tests.fixtures.custom_error_handler', ) importer = get_importer(conf) expect(importer).not_to_be_null() expect(importer.error_handler_class).not_to_be_null() expect(importer.error_handler_class).to_be_instance_of(CustomErrorHandler)
def test_can_import_default_modules(self): conf = Config() importer = get_importer(conf) expect(importer).not_to_be_null() expect(importer.filters).not_to_be_empty()
#!/usr/bin/python # -*- coding: utf-8 -*- import os from thumbor.console import get_server_parameters from thumbor.server import get_config, configure_log from thumbor.server import get_importer, validate_config from thumbor.server import get_context, get_application thumbor_port = os.environ.get('THUMBOR_PORT') or '8000' log_level = os.environ.get('LOG_LEVEL') or 'info' arguments = [ '--conf=/app/thumbor.conf', '--port=' + thumbor_port, '--log-level=' + log_level ] server_parameters = get_server_parameters(arguments) config = get_config(server_parameters.config_path) configure_log(config, server_parameters.log_level.upper()) importer = get_importer(config) validate_config(config, server_parameters) context = get_context(server_parameters, config, importer) application = get_application(context)
def get_importer(self): return get_importer(self.config)