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
17 changes: 17 additions & 0 deletions testing/test_awswrangler/test_moto.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from unittest.mock import ANY

import boto3
import botocore
import mock
Expand Down Expand Up @@ -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):
Expand Down