Exemple #1
0
 def topic(self):
     config = Config(AUTO_WEBP=True)
     context = Context(config=config)
     return Storage(context)
Exemple #2
0
 def get_config(self):
     self.tmp = tempfile.NamedTemporaryFile(prefix='thumborTest.')
     return Config(SECURITY_KEY='ACME-SEC', ERROR_FILE_LOGGER=self.tmp.name)
Exemple #3
0
 def get_config(self):
     return Config(FILE_STORAGE_ROOT_PATH="/tmp/thumbor/file_storage/",
                   STORAGE_EXPIRATION_SECONDS=None)
Exemple #4
0
 def setUp(self):
     config = Config(FILE_LOADER_ROOT_PATH=STORAGE_PATH)
     self.ctx = Context(config=config)
 def topic(self):
     config = Config()
     config.ALLOWED_SOURCES = ['s.glbimg.com']
     ctx = Context(None, config, None)
     is_valid = loader.validate(ctx, 'https://www.google.com/logo.jpg')
     return is_valid
 def topic(self):
     conf = Config()
     conf.METRICS = 'tc_prometheus.metrics.prometheus_metrics'
     imp = Importer(conf)
     imp.import_modules()
     return Context(None, conf, imp)
Exemple #7
0
 def topic(self):
     cfg = Config()
     ErrorHandler(cfg)
Exemple #8
0
 def test_default_values(self):
     cfg = Config()
     for key, default_value in self.get_config():
         config_value = getattr(cfg, key)
         expect(config_value).not_to_be_null()
         expect(config_value).to_equal(default_value)
Exemple #9
0
 def test_config_is_an_alias(self):
     Config.alias('OTHER_ENGINE', 'ENGINE')
     cfg = Config(OTHER_ENGINE='x')
     expect(cfg.ENGINE).to_equal('x')
     expect(cfg.OTHER_ENGINE).to_equal('x')
 def topic(self):
     config = Config()
     context = Context(config=config)
     context.request = RequestParameters(url='image.jpg')
     fs = NoStorage(context)
     return fs.put(100)
Exemple #11
0
 def test_config_is_an_aliased_key(self):
     Config.alias('LOADER_ALIAS', 'LOADER')
     cfg = Config(LOADER='y')
     expect(cfg.LOADER).to_equal('y')
     expect(cfg.LOADER_ALIAS).to_equal('y')
 def topic(self, callback):
     config = Config()
     context = Context(config=config)
     context.request = RequestParameters(url='image.jpg')
     fs = NoStorage(context)
     fs.get(callback=callback)
Exemple #13
0
 def topic(self):
     return Storage(
         Context(config=Config(STORAGE_EXPIRATION_SECONDS=0)))
Exemple #14
0
 def topic(self):
     config = Config(AUTO_WEBP=False)
     context = Context(config=config)
     context.request = RequestParameters(accepts_webp=True)
     return Storage(context)
Exemple #15
0
 def get_config(self):
     return Config(
         RESULT_STORAGE_FILE_STORAGE_ROOT_PATH=self.get_fixture_path(),
         RESULT_STORAGE_EXPIRATION_SECONDS=10)
Exemple #16
0
 def topic(self):
     config = Config(REDIS_STORAGE_SERVER_PORT=7778, REDIS_STORAGE_SERVER_PASSWORD='******', STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True)
     storage = RedisStorage(Context(config=config, server=get_server('ACME-SEC')))
     return storage.get_crypto(IMAGE_URL % 9999)
Exemple #17
0
        def topic(self, callback):
            config = Config(CASSANDRA_LOADER_KEYSPACE='general', CASSANDRA_LOADER_SERVER_PORT=9042,
                            CASSANDRA_LOADER_SERVER_HOST='localhost', CASSANDRA_LOADER_TABLE_NAME='images',
                            CASSANDRA_LOADER_TABLE_ID_COLUMN='image_id', CASSANDRA_LOADER_TABLE_BLOB_COLUMN='image_data')

            return loader.load(Context(config=config), 'not_here', callback)
Exemple #18
0
 def topic(self):
     config = Config(REDIS_STORAGE_SERVER_PORT=7778, REDIS_STORAGE_SERVER_PASSWORD='******')
     storage = RedisStorage(Context(config=config, server=get_server('ACME-SEC')))
     return storage.get_detector_data(IMAGE_URL % 10000)
Exemple #19
0
 def get_context(self):
     cfg = Config()
     ctx = Context(None, cfg, None)
     ctx.request = RequestParameters(url="image.jpg")
     self.context = ctx
     return ctx
Exemple #20
0
 def topic(self):
     config = Config(REDIS_STORAGE_SERVER_PORT=7778, REDIS_STORAGE_SERVER_PASSWORD='******')
     storage = RedisStorage(Context(config=config, server=get_server('ACME-SEC')))
     storage.put(IMAGE_URL % 10001, IMAGE_BYTES)
     storage.remove(IMAGE_URL % 10001)
     return self.parent.connection.get(IMAGE_URL % 10001)
Exemple #21
0
 def get_context(self):
     cfg = Config()
     return Context(None, cfg, None)
Exemple #22
0
        def topic(self):
            config = Config(REDIS_STORAGE_SERVER_PORT=7778, REDIS_STORAGE_SERVER_PASSWORD='******')
            storage = RedisStorage(Context(config=config, server=get_server('ACME-SEC')))

            storage.put(IMAGE_URL % 2, IMAGE_BYTES)
            return storage.get(IMAGE_URL % 2)
 def get_context(self):
     conf = Config()
     conf.METRICS = "thumbor.metrics.statsd_metrics"
     imp = Importer(conf)
     imp.import_modules()
     return Context(None, conf, imp)
Exemple #24
0
 def topic(self):
     config = Config(REDIS_STORAGE_SERVER_PORT=7778, REDIS_STORAGE_SERVER_PASSWORD='******', STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True)
     storage = RedisStorage(Context(config=config, server=get_server('')))
     storage.put(IMAGE_URL % 3, IMAGE_BYTES)
     storage.put_crypto(IMAGE_URL % 3)
Exemple #25
0
 def test_WhenInvalidConfigurationOfFileNameWithContext_should_be_error(self):
     cfg = Config(ERROR_FILE_NAME_USE_CONTEXT='server..port', ERROR_FILE_LOGGER='toto')
     with expect.error_to_happen(RuntimeError):
         ErrorHandler(cfg)
Exemple #26
0
 def get_config(self):
     return Config(AUTO_WEBP=True,
                   RESULT_STORAGE_FILE_STORAGE_ROOT_PATH=
                   "/tmp/thumbor/result_storages%s" %
                   (random.choice(['', '/'])))
Exemple #27
0
 def test_without_allowed_sources(self):
     config = Config()
     config.ALLOWED_SOURCES = []
     ctx = Context(None, config, None)
     is_valid = loader.validate(ctx, "http://www.google.com/logo.jpg")
     expect(is_valid).to_be_true()
Exemple #28
0
 def get_config(self):
     return Config(
         RESULT_STORAGE_FILE_STORAGE_ROOT_PATH=self.get_fixture_path())
Exemple #29
0
 def get_config(self):
     return Config(FILE_STORAGE_ROOT_PATH="/tmp/thumbor/file_storage/",
                   STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True)
Exemple #30
0
 def topic(self):
     config = Config(TC_AWS_STORAGE_ROOT_PATH='',
                     TC_AWS_ROOT_IMAGE_NAME='root_image')
     return Storage(Context(config=config))