def get_s3_client(target, aws_access_key_id, aws_secret_access_key, region_name): s3_uri = s3.parse_s3_uri(target) s3_client = boto3.client( 's3', aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, region_name=region_name, ) return s3.S3SyncClient(s3_client, s3_uri.bucket, s3_uri.key)
def test_correct_output(self): actual_output = s3.parse_s3_uri("s3://fruit.bowl/apples/and/oranges/") assert actual_output.bucket == "fruit.bowl" assert actual_output.key == "apples/and/oranges/"
def test_no_path(self): assert s3.parse_s3_uri("s3://bucket") is None
def test_incorrect_format(self): assert s3.parse_s3_uri("nos3infront/some/path") is None assert s3.parse_s3_uri(":/232red+-32") is None
def test_empty(self): assert s3.parse_s3_uri("") is None
def test_correct_output(self): actual_output = s3.parse_s3_uri('s3://fruit.bowl/apples/and/oranges/') assert actual_output.bucket == 'fruit.bowl' assert actual_output.key == 'apples/and/oranges/'