Skip to content

Commit

Permalink
Fix test runs
Browse files Browse the repository at this point in the history
  • Loading branch information
yakky committed Jan 1, 2017
2 parents 5b90ef9 + f2c6650 commit 4d7530b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
4 changes: 2 additions & 2 deletions filer/admin/folderadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from django.shortcuts import get_object_or_404, render
from django.utils.encoding import force_text
from django.utils.html import escape
from django.utils.http import urlquote
from django.utils.http import urlquote, urlunquote
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy, ungettext
Expand Down Expand Up @@ -287,7 +287,7 @@ def directory_listing(self, request, folder_id=None, viewtype=None):
# search
q = request.GET.get('q', None)
if q:
search_terms = unquote(q).split(" ")
search_terms = urlunquote(q).split(" ")
search_mode = True
else:
search_terms = []
Expand Down
23 changes: 23 additions & 0 deletions filer/tests/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,29 @@ class DontSearchOwnerEmailFolderAdmin(FolderAdmin):
folder_qs = folderadmin.filter_folder(Folder.objects.all(), ['[email protected]'])
self.assertEqual(len(folder_qs), 0)

def test_search_special_characters(self):
"""
Regression test for https://github.com/divio/django-filer/pull/945.
Because of a wrong unquoting function being used, searches with
some "_XX" sequences got unquoted as unicode characters.
For example, "_ec" gets unquoted as u'ì'.
"""
url = reverse('admin:filer-directory_listing',
kwargs={'folder_id': self.parent.id})

# Create a file with a problematic filename
problematic_file = django.core.files.base.ContentFile('some data')
filename = u'christopher_eccleston'
problematic_file.name = filename
self.spam_file = File.objects.create(
owner=self.staff_user, original_filename=filename,
file=problematic_file, folder=self.parent)

# Valid search for the filename, should have one result
response = self.client.get(url, {'q': filename})
item_list = response.context['paginated_items'].object_list
self.assertEqual(len(item_list), 1)


class FilerAdminContextTests(TestCase, BulkOperationsMixin):
def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion filer/tests/migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import django
from django.core.management import call_command
from django.test import TestCase
from six import StringIO
from django.utils.six import StringIO


class MigrationsTests(TestCase):
Expand Down
3 changes: 0 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
; currently broken. This functionality will be re-added (or
; re-designed later).
[tox]
toxworkdir = {homedir}/.toxenvs/django-filer
envlist =
flake8
; easy-thumbnails 1.x supports py27 only and has no dj17+ migrations
Expand Down Expand Up @@ -47,8 +46,6 @@ commands =
- coverage erase
coverage run test_settings.py {posargs}
- coverage report
passenv =
HOME
setenv =
custom_image: CUSTOM_IMAGE=filer.test_utils.custom_image.models.Image
deps =
Expand Down

0 comments on commit 4d7530b

Please sign in to comment.