def test_get_s3_file_object_http_400_error():
"""
Tests Get S3 file object with HTTP 400 error. Looks like HTTP 400 is
returned when AWS token expires and S3.Object.load is called.
"""
load_method = MagicMock(
side_effect=botocore.exceptions.ClientError(
{'Error': {'Code': u'400', 'Message': 'Bad Request'}},
operation_name='mock load'))
s3object = MagicMock(load=load_method)
client = Mock()
client.Object.return_value = s3object
client.load.return_value = None
type(client).s3path = PropertyMock(return_value='s3://testbucket/')
meta = {
u'client': client,
u'stage_info': {
u'location': 'sfc-teststage/rwyitestacco/users/1234/',
u'locationType': 'S3',
}
}
filename = "/path1/file2.txt"
akey = SnowflakeS3Util.get_file_header(meta, filename)
assert akey is None
assert meta['result_status'] == ResultStatus.RENEW_TOKEN
test_unit_s3_util.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录