diff --git a/testing/test_awswrangler/test_moto.py b/testing/test_awswrangler/test_moto.py index bccb200e1..71367f730 100644 --- a/testing/test_awswrangler/test_moto.py +++ b/testing/test_awswrangler/test_moto.py @@ -1,3 +1,5 @@ +from unittest.mock import ANY + import boto3 import botocore import mock @@ -219,6 +221,21 @@ def test_csv(s3): assert len(df.columns) == 10 +@mock.patch("pandas.read_csv") +@mock.patch("s3fs.S3FileSystem.open") +def test_read_csv_pass_pandas_arguments_and_encoding_succeed(mock_open, mock_read_csv, s3): + bucket = "bucket" + key = "foo/foo.csv" + path = "s3://{}/{}".format(bucket, key) + s3_object = s3.Object(bucket, key) + s3_object.put(Body=b"foo") + + with pytest.raises(TypeError): + wr.s3.read_csv(path=path, encoding="ISO-8859-1", sep=",", lineterminator="\r\n") + mock_open.assert_called_with(path="s3://bucket/foo/foo.csv", mode="r", encoding="ISO-8859-1", newline="\r\n") + mock_read_csv.assert_called_with(ANY, compression=None, encoding="ISO-8859-1", sep=",", lineterminator="\r\n") + + def test_to_csv_invalid_argument_combination_raise_when_dataset_false_succeed(s3): path = "s3://bucket/test.csv" with pytest.raises(InvalidArgumentCombination):