當前位置: 首頁>>代碼示例>>Python>>正文


Python Connection.make_request方法代碼示例

本文整理匯總了Python中test.functional.s3api.s3_test_client.Connection.make_request方法的典型用法代碼示例。如果您正苦於以下問題:Python Connection.make_request方法的具體用法?Python Connection.make_request怎麽用?Python Connection.make_request使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在test.functional.s3api.s3_test_client.Connection的用法示例。


在下文中一共展示了Connection.make_request方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_put_object_copy_error

# 需要導入模塊: from test.functional.s3api.s3_test_client import Connection [as 別名]
# 或者: from test.functional.s3api.s3_test_client.Connection import make_request [as 別名]
    def test_put_object_copy_error(self):
        obj = 'object'
        self.conn.make_request('PUT', self.bucket, obj)
        dst_bucket = 'dst-bucket'
        self.conn.make_request('PUT', dst_bucket)
        dst_obj = 'dst_object'

        headers = {'x-amz-copy-source': '/%s/%s' % (self.bucket, obj)}
        auth_error_conn = Connection(aws_secret_key='invalid')
        status, headers, body = \
            auth_error_conn.make_request('PUT', dst_bucket, dst_obj, headers)
        self.assertEqual(get_error_code(body), 'SignatureDoesNotMatch')
        self.assertEqual(headers['content-type'], 'application/xml')

        # /src/nothing -> /dst/dst
        headers = {'X-Amz-Copy-Source': '/%s/%s' % (self.bucket, 'nothing')}
        status, headers, body = \
            self.conn.make_request('PUT', dst_bucket, dst_obj, headers)
        self.assertEqual(get_error_code(body), 'NoSuchKey')
        self.assertEqual(headers['content-type'], 'application/xml')

        # /nothing/src -> /dst/dst
        headers = {'X-Amz-Copy-Source': '/%s/%s' % ('nothing', obj)}
        status, headers, body = \
            self.conn.make_request('PUT', dst_bucket, dst_obj, headers)
        # TODO: source bucket is not check.
        # self.assertEqual(get_error_code(body), 'NoSuchBucket')

        # /src/src -> /nothing/dst
        headers = {'X-Amz-Copy-Source': '/%s/%s' % (self.bucket, obj)}
        status, headers, body = \
            self.conn.make_request('PUT', 'nothing', dst_obj, headers)
        self.assertEqual(get_error_code(body), 'NoSuchBucket')
        self.assertEqual(headers['content-type'], 'application/xml')
開發者ID:jgmerritt,項目名稱:swift,代碼行數:36,代碼來源:test_object.py

示例2: test_upload_part_error

# 需要導入模塊: from test.functional.s3api.s3_test_client import Connection [as 別名]
# 或者: from test.functional.s3api.s3_test_client.Connection import make_request [as 別名]
    def test_upload_part_error(self):
        bucket = 'bucket'
        self.conn.make_request('PUT', bucket)
        query = 'uploads'
        key = 'obj'
        status, headers, body = \
            self.conn.make_request('POST', bucket, key, query=query)
        elem = fromstring(body, 'InitiateMultipartUploadResult')
        upload_id = elem.find('UploadId').text

        query = 'partNumber=%s&uploadId=%s' % (1, upload_id)
        auth_error_conn = Connection(aws_secret_key='invalid')
        status, headers, body = \
            auth_error_conn.make_request('PUT', bucket, key, query=query)
        self.assertEqual(get_error_code(body), 'SignatureDoesNotMatch')

        status, headers, body = \
            self.conn.make_request('PUT', 'nothing', key, query=query)
        self.assertEqual(get_error_code(body), 'NoSuchBucket')

        query = 'partNumber=%s&uploadId=%s' % (1, 'nothing')
        status, headers, body = \
            self.conn.make_request('PUT', bucket, key, query=query)
        self.assertEqual(get_error_code(body), 'NoSuchUpload')

        query = 'partNumber=%s&uploadId=%s' % (0, upload_id)
        status, headers, body = \
            self.conn.make_request('PUT', bucket, key, query=query)
        self.assertEqual(get_error_code(body), 'InvalidArgument')
        err_msg = 'Part number must be an integer between 1 and'
        self.assertTrue(err_msg in get_error_msg(body))
開發者ID:jgmerritt,項目名稱:swift,代碼行數:33,代碼來源:test_multi_upload.py

示例3: test_abort_multi_upload_error

# 需要導入模塊: from test.functional.s3api.s3_test_client import Connection [as 別名]
# 或者: from test.functional.s3api.s3_test_client.Connection import make_request [as 別名]
    def test_abort_multi_upload_error(self):
        bucket = 'bucket'
        self.conn.make_request('PUT', bucket)
        key = 'obj'
        query = 'uploads'
        status, headers, body = \
            self.conn.make_request('POST', bucket, key, query=query)
        elem = fromstring(body, 'InitiateMultipartUploadResult')
        upload_id = elem.find('UploadId').text
        self._upload_part(bucket, key, upload_id)

        query = 'uploadId=%s' % upload_id
        auth_error_conn = Connection(aws_secret_key='invalid')
        status, headers, body = \
            auth_error_conn.make_request('DELETE', bucket, key, query=query)
        self.assertEqual(get_error_code(body), 'SignatureDoesNotMatch')

        status, headers, body = \
            self.conn.make_request('DELETE', 'nothing', key, query=query)
        self.assertEqual(get_error_code(body), 'NoSuchBucket')

        status, headers, body = \
            self.conn.make_request('DELETE', bucket, 'nothing', query=query)
        self.assertEqual(get_error_code(body), 'NoSuchUpload')

        query = 'uploadId=%s' % 'nothing'
        status, headers, body = \
            self.conn.make_request('DELETE', bucket, key, query=query)
        self.assertEqual(get_error_code(body), 'NoSuchUpload')
開發者ID:jgmerritt,項目名稱:swift,代碼行數:31,代碼來源:test_multi_upload.py

示例4: test_put_object_error

# 需要導入模塊: from test.functional.s3api.s3_test_client import Connection [as 別名]
# 或者: from test.functional.s3api.s3_test_client.Connection import make_request [as 別名]
    def test_put_object_error(self):
        auth_error_conn = Connection(aws_secret_key='invalid')
        status, headers, body = \
            auth_error_conn.make_request('PUT', self.bucket, 'object')
        self.assertEqual(get_error_code(body), 'SignatureDoesNotMatch')
        self.assertEqual(headers['content-type'], 'application/xml')

        status, headers, body = \
            self.conn.make_request('PUT', 'bucket2', 'object')
        self.assertEqual(get_error_code(body), 'NoSuchBucket')
        self.assertEqual(headers['content-type'], 'application/xml')
開發者ID:jgmerritt,項目名稱:swift,代碼行數:13,代碼來源:test_object.py

示例5: test_delete_bucket_error

# 需要導入模塊: from test.functional.s3api.s3_test_client import Connection [as 別名]
# 或者: from test.functional.s3api.s3_test_client.Connection import make_request [as 別名]
    def test_delete_bucket_error(self):
        status, headers, body = \
            self.conn.make_request('DELETE', 'bucket+invalid')
        self.assertEqual(get_error_code(body), 'InvalidBucketName')

        auth_error_conn = Connection(aws_secret_key='invalid')
        status, headers, body = \
            auth_error_conn.make_request('DELETE', 'bucket')
        self.assertEqual(get_error_code(body), 'SignatureDoesNotMatch')

        status, headers, body = self.conn.make_request('DELETE', 'bucket')
        self.assertEqual(get_error_code(body), 'NoSuchBucket')
開發者ID:openstack,項目名稱:swift,代碼行數:14,代碼來源:test_bucket.py

示例6: test_put_bucket_error

# 需要導入模塊: from test.functional.s3api.s3_test_client import Connection [as 別名]
# 或者: from test.functional.s3api.s3_test_client.Connection import make_request [as 別名]
    def test_put_bucket_error(self):
        status, headers, body = \
            self.conn.make_request('PUT', 'bucket+invalid')
        self.assertEqual(get_error_code(body), 'InvalidBucketName')

        auth_error_conn = Connection(aws_secret_key='invalid')
        status, headers, body = auth_error_conn.make_request('PUT', 'bucket')
        self.assertEqual(get_error_code(body), 'SignatureDoesNotMatch')

        self.conn.make_request('PUT', 'bucket')
        status, headers, body = self.conn.make_request('PUT', 'bucket')
        self.assertEqual(get_error_code(body), 'BucketAlreadyExists')
開發者ID:matthewoliver,項目名稱:swift,代碼行數:14,代碼來源:test_bucket.py

示例7: test_get_bucket_acl_error

# 需要導入模塊: from test.functional.s3api.s3_test_client import Connection [as 別名]
# 或者: from test.functional.s3api.s3_test_client.Connection import make_request [as 別名]
    def test_get_bucket_acl_error(self):
        aws_error_conn = Connection(aws_secret_key='invalid')
        status, headers, body = \
            aws_error_conn.make_request('GET', self.bucket, query='acl')
        self.assertEqual(get_error_code(body), 'SignatureDoesNotMatch')

        status, headers, body = \
            self.conn.make_request('GET', 'nothing', query='acl')
        self.assertEqual(get_error_code(body), 'NoSuchBucket')

        status, headers, body = \
            self.conn2.make_request('GET', self.bucket, query='acl')
        self.assertEqual(get_error_code(body), 'AccessDenied')
開發者ID:matthewoliver,項目名稱:swift,代碼行數:15,代碼來源:test_acl.py

示例8: test_list_multi_uploads_error

# 需要導入模塊: from test.functional.s3api.s3_test_client import Connection [as 別名]
# 或者: from test.functional.s3api.s3_test_client.Connection import make_request [as 別名]
    def test_list_multi_uploads_error(self):
        bucket = 'bucket'
        self.conn.make_request('PUT', bucket)
        query = 'uploads'

        auth_error_conn = Connection(aws_secret_key='invalid')
        status, headers, body = \
            auth_error_conn.make_request('GET', bucket, query=query)
        self.assertEqual(get_error_code(body), 'SignatureDoesNotMatch')

        status, headers, body = \
            self.conn.make_request('GET', 'nothing', query=query)
        self.assertEqual(get_error_code(body), 'NoSuchBucket')
開發者ID:jgmerritt,項目名稱:swift,代碼行數:15,代碼來源:test_multi_upload.py

示例9: test_put_bucket_error_key3

# 需要導入模塊: from test.functional.s3api.s3_test_client import Connection [as 別名]
# 或者: from test.functional.s3api.s3_test_client.Connection import make_request [as 別名]
    def test_put_bucket_error_key3(self):
        if 's3_access_key3' not in tf.config or \
                's3_secret_key3' not in tf.config:
            raise tf.SkipTest('Cannot test for AccessDenied; need '
                              's3_access_key3 and s3_secret_key3 configured')

        self.conn.make_request('PUT', 'bucket')
        # If the user can't create buckets, they shouldn't even know
        # whether the bucket exists.
        conn3 = Connection(tf.config['s3_access_key3'],
                           tf.config['s3_secret_key3'],
                           tf.config['s3_access_key3'])
        status, headers, body = conn3.make_request('PUT', 'bucket')
        self.assertEqual(status, 403)
        self.assertEqual(get_error_code(body), 'AccessDenied')
開發者ID:openstack,項目名稱:swift,代碼行數:17,代碼來源:test_bucket.py

示例10: test_upload_part_copy_error

# 需要導入模塊: from test.functional.s3api.s3_test_client import Connection [as 別名]
# 或者: from test.functional.s3api.s3_test_client.Connection import make_request [as 別名]
    def test_upload_part_copy_error(self):
        src_bucket = 'src'
        src_obj = 'src'
        self.conn.make_request('PUT', src_bucket)
        self.conn.make_request('PUT', src_bucket, src_obj)
        src_path = '%s/%s' % (src_bucket, src_obj)

        bucket = 'bucket'
        self.conn.make_request('PUT', bucket)
        key = 'obj'
        query = 'uploads'
        status, headers, body = \
            self.conn.make_request('POST', bucket, key, query=query)
        elem = fromstring(body, 'InitiateMultipartUploadResult')
        upload_id = elem.find('UploadId').text

        query = 'partNumber=%s&uploadId=%s' % (1, upload_id)
        auth_error_conn = Connection(aws_secret_key='invalid')
        status, headers, body = \
            auth_error_conn.make_request('PUT', bucket, key,
                                         headers={
                                             'X-Amz-Copy-Source': src_path
                                         },
                                         query=query)
        self.assertEqual(get_error_code(body), 'SignatureDoesNotMatch')

        status, headers, body = \
            self.conn.make_request('PUT', 'nothing', key,
                                   headers={'X-Amz-Copy-Source': src_path},
                                   query=query)
        self.assertEqual(get_error_code(body), 'NoSuchBucket')

        query = 'partNumber=%s&uploadId=%s' % (1, 'nothing')
        status, headers, body = \
            self.conn.make_request('PUT', bucket, key,
                                   headers={'X-Amz-Copy-Source': src_path},
                                   query=query)
        self.assertEqual(get_error_code(body), 'NoSuchUpload')

        src_path = '%s/%s' % (src_bucket, 'nothing')
        query = 'partNumber=%s&uploadId=%s' % (1, upload_id)
        status, headers, body = \
            self.conn.make_request('PUT', bucket, key,
                                   headers={'X-Amz-Copy-Source': src_path},
                                   query=query)
        self.assertEqual(get_error_code(body), 'NoSuchKey')
開發者ID:jgmerritt,項目名稱:swift,代碼行數:48,代碼來源:test_multi_upload.py

示例11: test_head_bucket_error

# 需要導入模塊: from test.functional.s3api.s3_test_client import Connection [as 別名]
# 或者: from test.functional.s3api.s3_test_client.Connection import make_request [as 別名]
    def test_head_bucket_error(self):
        self.conn.make_request('PUT', 'bucket')

        status, headers, body = \
            self.conn.make_request('HEAD', 'bucket+invalid')
        self.assertEqual(status, 400)
        self.assertEqual(body, '')  # sanity

        auth_error_conn = Connection(aws_secret_key='invalid')
        status, headers, body = \
            auth_error_conn.make_request('HEAD', 'bucket')
        self.assertEqual(status, 403)
        self.assertEqual(body, '')  # sanity

        status, headers, body = self.conn.make_request('HEAD', 'nothing')
        self.assertEqual(status, 404)
        self.assertEqual(body, '')  # sanity
開發者ID:openstack,項目名稱:swift,代碼行數:19,代碼來源:test_bucket.py

示例12: test_put_bucket_error_key2

# 需要導入模塊: from test.functional.s3api.s3_test_client import Connection [as 別名]
# 或者: from test.functional.s3api.s3_test_client.Connection import make_request [as 別名]
    def test_put_bucket_error_key2(self):
        if config_true_value(tf.cluster_info['s3api'].get('s3_acl')):
            if 's3_access_key2' not in tf.config or \
                    's3_secret_key2' not in tf.config:
                raise tf.SkipTest(
                    'Cannot test for BucketAlreadyExists with second user; '
                    'need s3_access_key2 and s3_secret_key2 configured')

            self.conn.make_request('PUT', 'bucket')

            # Other users of the same account get the same 409 error
            conn2 = Connection(tf.config['s3_access_key2'],
                               tf.config['s3_secret_key2'],
                               tf.config['s3_access_key2'])
            status, headers, body = conn2.make_request('PUT', 'bucket')
            self.assertEqual(status, 409)
            self.assertEqual(get_error_code(body), 'BucketAlreadyExists')
開發者ID:openstack,項目名稱:swift,代碼行數:19,代碼來源:test_bucket.py

示例13: test_put_bucket_acl_error

# 需要導入模塊: from test.functional.s3api.s3_test_client import Connection [as 別名]
# 或者: from test.functional.s3api.s3_test_client.Connection import make_request [as 別名]
    def test_put_bucket_acl_error(self):
        req_headers = {'x-amz-acl': 'public-read'}
        aws_error_conn = Connection(aws_secret_key='invalid')
        status, headers, body = \
            aws_error_conn.make_request('PUT', self.bucket,
                                        headers=req_headers, query='acl')
        self.assertEqual(get_error_code(body), 'SignatureDoesNotMatch')

        status, headers, body = \
            self.conn.make_request('PUT', 'nothing',
                                   headers=req_headers, query='acl')
        self.assertEqual(get_error_code(body), 'NoSuchBucket')

        status, headers, body = \
            self.conn2.make_request('PUT', self.bucket,
                                    headers=req_headers, query='acl')
        self.assertEqual(get_error_code(body), 'AccessDenied')
開發者ID:matthewoliver,項目名稱:swift,代碼行數:19,代碼來源:test_acl.py

示例14: test_head_object_error

# 需要導入模塊: from test.functional.s3api.s3_test_client import Connection [as 別名]
# 或者: from test.functional.s3api.s3_test_client.Connection import make_request [as 別名]
    def test_head_object_error(self):
        obj = 'object'
        self.conn.make_request('PUT', self.bucket, obj)

        auth_error_conn = Connection(aws_secret_key='invalid')
        status, headers, body = \
            auth_error_conn.make_request('HEAD', self.bucket, obj)
        self.assertEqual(status, 403)
        self.assertEqual(body, '')  # sanity
        self.assertEqual(headers['content-type'], 'application/xml')

        status, headers, body = \
            self.conn.make_request('HEAD', self.bucket, 'invalid')
        self.assertEqual(status, 404)
        self.assertEqual(body, '')  # sanity
        self.assertEqual(headers['content-type'], 'application/xml')

        status, headers, body = \
            self.conn.make_request('HEAD', 'invalid', obj)
        self.assertEqual(status, 404)
        self.assertEqual(body, '')  # sanity
        self.assertEqual(headers['content-type'], 'application/xml')
開發者ID:jgmerritt,項目名稱:swift,代碼行數:24,代碼來源:test_object.py

示例15: test_service_error_signature_not_match

# 需要導入模塊: from test.functional.s3api.s3_test_client import Connection [as 別名]
# 或者: from test.functional.s3api.s3_test_client.Connection import make_request [as 別名]
 def test_service_error_signature_not_match(self):
     auth_error_conn = Connection(aws_secret_key='invalid')
     status, headers, body = auth_error_conn.make_request('GET')
     self.assertEqual(get_error_code(body), 'SignatureDoesNotMatch')
     self.assertEqual(headers['content-type'], 'application/xml')
開發者ID:jgmerritt,項目名稱:swift,代碼行數:7,代碼來源:test_service.py


注:本文中的test.functional.s3api.s3_test_client.Connection.make_request方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。