예제 #1
0
 def topic(self):
     config = Config(AUTO_WEBP=True)
     context = Context(config=config)
     return Storage(context)
예제 #2
0
 def get_config(self):
     self.tmp = tempfile.NamedTemporaryFile(prefix='thumborTest.')
     return Config(SECURITY_KEY='ACME-SEC', ERROR_FILE_LOGGER=self.tmp.name)
예제 #3
0
 def get_config(self):
     return Config(FILE_STORAGE_ROOT_PATH="/tmp/thumbor/file_storage/",
                   STORAGE_EXPIRATION_SECONDS=None)
예제 #4
0
 def setUp(self):
     config = Config(FILE_LOADER_ROOT_PATH=STORAGE_PATH)
     self.ctx = Context(config=config)
예제 #5
0
 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
예제 #6
0
 def topic(self):
     conf = Config()
     conf.METRICS = 'tc_prometheus.metrics.prometheus_metrics'
     imp = Importer(conf)
     imp.import_modules()
     return Context(None, conf, imp)
예제 #7
0
 def topic(self):
     cfg = Config()
     ErrorHandler(cfg)
예제 #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)
예제 #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)
예제 #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)
예제 #13
0
 def topic(self):
     return Storage(
         Context(config=Config(STORAGE_EXPIRATION_SECONDS=0)))
예제 #14
0
 def topic(self):
     config = Config(AUTO_WEBP=False)
     context = Context(config=config)
     context.request = RequestParameters(accepts_webp=True)
     return Storage(context)
예제 #15
0
 def get_config(self):
     return Config(
         RESULT_STORAGE_FILE_STORAGE_ROOT_PATH=self.get_fixture_path(),
         RESULT_STORAGE_EXPIRATION_SECONDS=10)
예제 #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)
예제 #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)
예제 #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)
예제 #19
0
 def get_context(self):
     cfg = Config()
     ctx = Context(None, cfg, None)
     ctx.request = RequestParameters(url="image.jpg")
     self.context = ctx
     return ctx
예제 #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)
예제 #21
0
 def get_context(self):
     cfg = Config()
     return Context(None, cfg, None)
예제 #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)
예제 #23
0
 def get_context(self):
     conf = Config()
     conf.METRICS = "thumbor.metrics.statsd_metrics"
     imp = Importer(conf)
     imp.import_modules()
     return Context(None, conf, imp)
예제 #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)
예제 #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)
예제 #26
0
 def get_config(self):
     return Config(AUTO_WEBP=True,
                   RESULT_STORAGE_FILE_STORAGE_ROOT_PATH=
                   "/tmp/thumbor/result_storages%s" %
                   (random.choice(['', '/'])))
예제 #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()
예제 #28
0
 def get_config(self):
     return Config(
         RESULT_STORAGE_FILE_STORAGE_ROOT_PATH=self.get_fixture_path())
예제 #29
0
 def get_config(self):
     return Config(FILE_STORAGE_ROOT_PATH="/tmp/thumbor/file_storage/",
                   STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True)
예제 #30
0
 def topic(self):
     config = Config(TC_AWS_STORAGE_ROOT_PATH='',
                     TC_AWS_ROOT_IMAGE_NAME='root_image')
     return Storage(Context(config=config))