def test_validate_gifsicle_path(self, which_mock): server_parameters = mock.Mock(security_key=None) conf = Config(SECURITY_KEY='test', USE_GIFSICLE_ENGINE=True) which_mock.return_value = '/usr/bin/gifsicle' validate_config(conf, server_parameters) expect(server_parameters.gifsicle_path).to_equal('/usr/bin/gifsicle')
def test_validate_gifsicle_path(self, which_mock): server_parameters = mock.Mock(security_key=None) conf = Config(SECURITY_KEY="test", USE_GIFSICLE_ENGINE=True) which_mock.return_value = "/usr/bin/gifsicle" validate_config(conf, server_parameters) expect(server_parameters.gifsicle_path).to_equal("/usr/bin/gifsicle")
def test_validate_config_security_key(self): server_parameters = mock.Mock(security_key=None) conf = Config(SECURITY_KEY=None) with expect.error_to_happen( RuntimeError, message="No security key was found for this instance of thumbor. " "Please provide one using the conf file or a security key file."): validate_config(conf, server_parameters)
def test_validate_null_gifsicle_path(self, which_mock): server_parameters = mock.Mock(security_key=None) conf = Config(SECURITY_KEY="test", USE_GIFSICLE_ENGINE=True) which_mock.return_value = None with expect.error_to_happen( RuntimeError, message="If using USE_GIFSICLE_ENGINE configuration to True, " "the `gifsicle` binary must be in the PATH and must be an executable.", ): validate_config(conf, server_parameters)
def test_validate_null_gifsicle_path(self, which_mock): server_parameters = mock.Mock(security_key=None) conf = Config(SECURITY_KEY='test', USE_GIFSICLE_ENGINE=True) which_mock.return_value = None with expect.error_to_happen( RuntimeError, message="If using USE_GIFSICLE_ENGINE configuration to True, " "the `gifsicle` binary must be in the PATH and must be an executable." ): validate_config(conf, server_parameters)
def get_server(self): server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'info', None) validate_config(self.config, server) return server
def test_validate_config_security_key_from_config(self): server_parameters = mock.Mock(security_key=None) conf = Config(SECURITY_KEY="something") validate_config(conf, server_parameters) expect(server_parameters.security_key).to_equal("something")
def test_validate_config_security_key_from_config(self): server_parameters = mock.Mock(security_key=None) conf = Config(SECURITY_KEY='something') validate_config(conf, server_parameters) expect(server_parameters.security_key).to_equal('something')
def get_server(self): server = ServerParameters(8889, "localhost", "thumbor.conf", None, "info", None) validate_config(self.config, server) return server
#!/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)