Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix urlib opener bug #8788

Merged
merged 1 commit into from
Dec 8, 2019
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions superset/tasks/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ def _get_slice_data(schedule):
raise URLError(response.getcode())

# TODO: Move to the csv module
rows = [r.split(b",") for r in response.content.splitlines()]
content = response.read()
rows = [r.split(b",") for r in content.splitlines()]

if schedule.delivery_type == EmailDeliveryType.inline:
data = None
Expand All @@ -281,7 +282,7 @@ def _get_slice_data(schedule):
)

elif schedule.delivery_type == EmailDeliveryType.attachment:
data = {__("%(name)s.csv", name=slc.slice_name): response.content}
data = {__("%(name)s.csv", name=slc.slice_name): content}
body = __(
'<b><a href="%(url)s">Explore in Superset</a></b><p></p>',
name=slc.slice_name,
Expand Down
5 changes: 2 additions & 3 deletions tests/schedules_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def test_deliver_slice_csv_attachment(
mock_open.return_value = response
mock_urlopen.return_value = response
mock_urlopen.return_value.getcode.return_value = 200
response.content = self.CSV
response.read.return_value = self.CSV

schedule = (
db.session.query(SliceEmailSchedule)
Expand All @@ -404,8 +404,7 @@ def test_deliver_slice_csv_inline(self, send_email_smtp, mock_open, mock_urlopen
mock_open.return_value = response
mock_urlopen.return_value = response
mock_urlopen.return_value.getcode.return_value = 200
response.content = self.CSV

response.read.return_value = self.CSV
schedule = (
db.session.query(SliceEmailSchedule)
.filter_by(id=self.slice_schedule)
Expand Down