Skip to content

Commit

Permalink
fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvin-muchiri committed Sep 30, 2024
1 parent 9bdd5d2 commit ad44270
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 5 additions & 5 deletions onadata/apps/api/tests/viewsets/test_entity_list_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,15 +544,15 @@ def test_render_csv(self):
self.assertEqual(
response.get("Content-Disposition"), "attachment; filename=trees.csv"
)
self.assertEqual(response["Content-Type"], "application/csv")
self.assertEqual(response["Content-Type"], "text/csv")
# Using `Accept` header
request = self.factory.get("/", HTTP_ACCEPT="text/csv", **self.extra)
response = self.view(request, pk=self.entity_list.pk)
self.assertEqual(response.status_code, 200)
self.assertEqual(
response.get("Content-Disposition"), "attachment; filename=trees.csv"
)
self.assertEqual(response["Content-Type"], "application/csv")
self.assertEqual(response["Content-Type"], "text/csv")


class DeleteEntityListTestCase(TestAbstractViewSet):
Expand Down Expand Up @@ -1709,23 +1709,23 @@ def test_download(self):
response = self.view(request, pk=self.entity_list.pk)
self.assertEqual(response.status_code, 200)
self.assertEqual(
response["Content-Disposition"], "attachment%3B%20filename%3Dtrees.csv"
response["Content-Disposition"], "attachment; filename=trees.csv"
)
self.assertEqual(response["Content-Type"], "text/csv")
# Using `.csv` suffix
request = self.factory.get("/", **self.extra)
response = self.view(request, pk=self.entity_list.pk, format="csv")
self.assertEqual(response.status_code, 200)
self.assertEqual(
response["Content-Disposition"], "attachment%3B%20filename%3Dtrees.csv"
response["Content-Disposition"], "attachment; filename=trees.csv"
)
self.assertEqual(response["Content-Type"], "text/csv")
# Using `Accept` header
request = self.factory.get("/", HTTP_ACCEPT="text/csv", **self.extra)
response = self.view(request, pk=self.entity_list.pk)
self.assertEqual(response.status_code, 200)
self.assertEqual(
response.get("Content-Disposition"), "attachment%3B%20filename%3Dtrees.csv"
response.get("Content-Disposition"), "attachment; filename=trees.csv"
)
self.assertEqual(response["Content-Type"], "text/csv")
# Unsupported suffix
Expand Down
3 changes: 1 addition & 2 deletions onadata/libs/utils/image_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Image utility functions module.
"""
import logging
import urllib
from datetime import datetime, timedelta
from tempfile import NamedTemporaryFile
from wsgiref.util import FileWrapper
Expand Down Expand Up @@ -42,7 +41,7 @@ def generate_media_download_url(
if not filename:
filename = file_path.split("/")[-1]

content_disposition = urllib.parse.quote(f"attachment; filename={filename}")
content_disposition = f"attachment; filename={filename}"
s3_class = None
azure = None

Expand Down

0 comments on commit ad44270

Please sign in to comment.