Skip to content

Commit

Permalink
Test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
palewire committed Oct 31, 2023
1 parent 7c2e213 commit 719e505
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 5 additions & 4 deletions datawrapper/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ def create_chart(
assert isinstance(obj, dict)

# Add data, if provided
if data:
if data is not None:
self.add_data(chart_id=obj["id"], data=data)

# Return the result
Expand Down Expand Up @@ -734,7 +734,7 @@ def update_chart(
_query["metadata"] = metadata

# If there's nothing there to update, raise an exception
if not _query and not data:
if not _query and data is None:
msg = "No updates submitted."
logger.error(msg)
raise InvalidRequest(msg)
Expand Down Expand Up @@ -1005,7 +1005,7 @@ def export_chart(
"transparent": transparent,
}

response = self.get(
content = self.get(
f"{self._CHARTS_URL}/{chart_id}/export/{output}", params=_query
)

Expand All @@ -1015,7 +1015,7 @@ def export_chart(

# Write the file to the file path
with open(_filepath, "wb") as fh:
fh.write(response.content)
fh.write(content)

# Display the image if requested
if display:
Expand Down Expand Up @@ -1102,6 +1102,7 @@ def add_data(self, chart_id: str, data: pd.DataFrame | str) -> bool:
return self.put(
f"{self._CHARTS_URL}/{chart_id}/data",
data=_data.encode("utf-8"),
extra_headers={"content-type": "text/csv"},
dump_data=False,
)

Expand Down
6 changes: 2 additions & 4 deletions tests/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ def test_get_user():
assert user["id"] == my_id

# Get recently edited and published charts
charts = dw.get_recently_edited_charts()
charts = dw.get_recently_edited_charts(user["id"])
assert isinstance(charts, dict)
assert isinstance(charts["charts"], list)

charts = dw.get_recently_published_charts()
charts = dw.get_recently_published_charts(user["id"])
assert isinstance(charts, dict)
assert isinstance(charts["charts"], list)


def test_edit_user():
Expand Down

0 comments on commit 719e505

Please sign in to comment.