mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-01 11:00:13 +03:00
added test_search_field_with_breaking_params
This commit is contained in:
parent
29cbe574a3
commit
cc93eb2457
|
@ -10,7 +10,7 @@ from django.test import TestCase
|
||||||
from django.test.utils import override_settings
|
from django.test.utils import override_settings
|
||||||
from django.utils.six.moves import reload_module
|
from django.utils.six.moves import reload_module
|
||||||
|
|
||||||
from rest_framework import filters, generics, serializers
|
from rest_framework import filters, generics, serializers, viewsets
|
||||||
from rest_framework.compat import coreschema
|
from rest_framework.compat import coreschema
|
||||||
from rest_framework.test import APIRequestFactory
|
from rest_framework.test import APIRequestFactory
|
||||||
|
|
||||||
|
@ -182,6 +182,18 @@ class SearchFilterTests(TestCase):
|
||||||
{'id': 3, 'title': 'zzz', 'text': 'cde'}
|
{'id': 3, 'title': 'zzz', 'text': 'cde'}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def test_search_field_with_breaking_params(self):
|
||||||
|
class SearchListViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
|
queryset = SearchFilterModel.objects.all()
|
||||||
|
serializer_class = SearchFilterSerializer
|
||||||
|
filter_backends = (filters.SearchFilter,)
|
||||||
|
search_fields = ('title', 'text')
|
||||||
|
|
||||||
|
view = SearchListViewSet.as_view({'get': 'list'})
|
||||||
|
request = factory.get('/', {'search': ',,,,'})
|
||||||
|
response = view(request)
|
||||||
|
assert len(response.data) == 0
|
||||||
|
|
||||||
|
|
||||||
class AttributeModel(models.Model):
|
class AttributeModel(models.Model):
|
||||||
label = models.CharField(max_length=32)
|
label = models.CharField(max_length=32)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user