コード例 #1
0
def test_json_asset_compresses():
    data = json.dumps({"a": '¿Dónde esta el baño?'})
    asset = S3resource(bucket=testbucket, content=data,
                       contenttype='application/json')
    result = asset.as_s3object()
    assert result['Body'] == gzip(data)
    assert result['ContentEncoding'] == 'gzip'
コード例 #2
0
ファイル: s3.py プロジェクト: veselosky/bluebucket
    def as_s3object(self, bucket=None):
        s3obj = dict(
            Bucket=bucket or self.bucket,
            Key=self.key,
            ContentType=self.contenttype,
            Metadata=self.metadata,
        )
        if self.is_compressible():
            s3obj['ContentEncoding'] = 'gzip'
            s3obj['Body'] = gzip(self.content)
        else:
            s3obj['Body'] = self.content
        if self.acl:
            s3obj['ACL'] = self.acl

        return s3obj
コード例 #3
0
ファイル: test_util.py プロジェクト: veselosky/bluebucket
def test_gzip_handling():
    text = 'This is my baño. There are many like it but this one is mine.'
    assert text == gunzip(gzip(text.encode('utf-8'))).decode('utf-8')
コード例 #4
0
def test_rss_compresses():
    asset = S3resource(bucket=testbucket, text='¿Dónde esta el baño?',
                       contenttype='application/rss+xml')
    result = asset.as_s3object()
    assert result['Body'] == gzip('¿Dónde esta el baño?'.encode('utf-8'))
    assert result['ContentEncoding'] == 'gzip'
コード例 #5
0
def test_text_asset_compresses():
    asset = S3resource(bucket=testbucket, text='¿Dónde esta el baño?',
                       contenttype='text/plain; charset=utf-8')
    result = asset.as_s3object()
    assert result['Body'] == gzip('¿Dónde esta el baño?'.encode('utf-8'))
    assert result['ContentEncoding'] == 'gzip'