Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions testing/test_awswrangler/test_moto.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import boto3
import mock
from botocore.exceptions import ClientError
import botocore
import moto
import pytest

Expand Down Expand Up @@ -52,6 +55,36 @@ def test_parquet(s3):
assert len(df.columns) == 18


def test_s3_delete_object_success(s3):
path = "s3://bucket/test.parquet"
wr.s3.to_parquet(df=get_df_list(), path=path, index=False, dataset=True, partition_cols=["par0", "par1"])
df = wr.s3.read_parquet(path=path, dataset=True)
ensure_data_types(df, has_list=True)

wr.s3.delete_objects(path=path)
with pytest.raises(OSError):
wr.s3.read_parquet(path=path, dataset=True)


def test_s3_raise_delete_object_exception_success(s3):
path = "s3://bucket/test.parquet"
wr.s3.to_parquet(df=get_df_list(), path=path, index=False, dataset=True, partition_cols=["par0", "par1"])
df = wr.s3.read_parquet(path=path, dataset=True)
ensure_data_types(df, has_list=True)

call = botocore.client.BaseClient._make_api_call

def mock_make_api_call(self, operation_name, kwarg):
if operation_name == 'DeleteObjects':
parsed_response = {'Error': {'Code': '500', 'Message': 'Test Error'}}
raise ClientError(parsed_response, operation_name)
return call(self, operation_name, kwarg)

with mock.patch('botocore.client.BaseClient._make_api_call', new=mock_make_api_call):
with pytest.raises(ClientError):
wr.s3.delete_objects(path=path)


def test_emr(s3, emr, sts, subnet):
session = boto3.Session(region_name="us-west-1")
cluster_id = wr.emr.create_cluster(
Expand Down