def topic(self):
            self.conn = S3Connection()
            self.conn.create_bucket(s3_bucket)

            config = Config(TC_AWS_RESULT_STORAGE_BUCKET=s3_bucket, TC_AWS_RESULT_STORAGE_ROOT_PATH='tata')
            ctx = Context(config=config, server=get_server('ACME-SEC'))

            storage = Storage(ctx)

            return storage._normalize_path('toto')
Пример #2
0
    def test_should_check_invalid_key(self):
        config = Config(TC_AWS_RESULT_STORAGE_BUCKET=s3_bucket,
                        TC_AWS_RESULT_STORAGE_ROOT_PATH='tata')
        ctx = Context(config=config, server=get_server('ACME-SEC'))

        storage = Storage(ctx)

        topic = storage._normalize_path('toto')

        self.assertEqual(topic, "tata/toto")
        def topic(self, callback):
            self.conn = S3Connection()
            self.conn.create_bucket(s3_bucket)

            config = Config(TC_AWS_RESULT_STORAGE_BUCKET=s3_bucket, TC_AWS_STORE_METADATA=True)
            ctx = Context(config=config, server=get_server('ACME-SEC'))
            ctx.headers = {'Content-Type': 'image/webp', 'Some-Other-Header': 'doge-header'}
            ctx.request = Request
            ctx.request.url = 'my-image-meta.jpg'

            storage = Storage(ctx)
            storage.put(IMAGE_BYTES)

            file_abspath = storage._normalize_path(ctx.request.url)
            storage.storage.get(file_abspath, callback=callback)
Пример #4
0
    def test_can_get_image_with_metadata(self):
        config = Config(TC_AWS_RESULT_STORAGE_BUCKET=s3_bucket,
                        TC_AWS_STORE_METADATA=True)
        ctx = Context(config=config, server=get_server('ACME-SEC'))
        ctx.headers = {
            'Content-Type': 'image/webp',
            'Some-Other-Header': 'doge-header'
        }
        ctx.request = Request
        ctx.request.url = 'my-image-meta.jpg'

        storage = Storage(ctx)
        yield storage.put(IMAGE_BYTES)

        file_abspath = storage._normalize_path(ctx.request.url)
        topic = yield storage.get(file_abspath)

        self.assertIn('Some-Other-Header', topic.metadata['Metadata'])
        self.assertEqual(topic.metadata['Metadata']['Content-Type'],
                         'image/webp')
        self.assertEqual(topic.buffer, IMAGE_BYTES)