mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 04:20:12 +03:00
Test showing behaviour of issue #1586 given Python3 and Internet Explorer behaviour on query strings
This commit is contained in:
parent
5c12b07681
commit
6c0624631e
|
@ -9,6 +9,7 @@ from django.test.client import Client as DjangoClient
|
||||||
from django.test.client import ClientHandler
|
from django.test.client import ClientHandler
|
||||||
from django.test import testcases
|
from django.test import testcases
|
||||||
from django.utils.http import urlencode
|
from django.utils.http import urlencode
|
||||||
|
from django.utils.six.moves.urllib.parse import unquote
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
from rest_framework.compat import RequestFactory as DjangoRequestFactory
|
from rest_framework.compat import RequestFactory as DjangoRequestFactory
|
||||||
from rest_framework.compat import force_bytes_or_smart_bytes, six
|
from rest_framework.compat import force_bytes_or_smart_bytes, six
|
||||||
|
@ -169,3 +170,16 @@ if django.VERSION >= (1, 4):
|
||||||
|
|
||||||
class APILiveServerTestCase(testcases.LiveServerTestCase):
|
class APILiveServerTestCase(testcases.LiveServerTestCase):
|
||||||
client_class = APIClient
|
client_class = APIClient
|
||||||
|
|
||||||
|
|
||||||
|
class IEClient(DjangoClient):
|
||||||
|
def request(self, **kwargs):
|
||||||
|
try:
|
||||||
|
kwargs['QUERY_STRING'] = unquote(kwargs['QUERY_STRING'])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return super(IEClient, self).request(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class IETestCase(testcases.TestCase):
|
||||||
|
client_class = IEClient
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
Tests for content parsing, and form-overloaded content parsing.
|
Tests for content parsing, and form-overloaded content parsing.
|
||||||
"""
|
"""
|
||||||
|
@ -19,7 +20,7 @@ from rest_framework.parsers import (
|
||||||
from rest_framework.request import Request, Empty
|
from rest_framework.request import Request, Empty
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
from rest_framework.test import APIRequestFactory, APIClient
|
from rest_framework.test import APIRequestFactory, APIClient, IETestCase
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
from rest_framework.compat import six
|
from rest_framework.compat import six
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
@ -272,6 +273,9 @@ class MockView(APIView):
|
||||||
|
|
||||||
return Response(status=status.INTERNAL_SERVER_ERROR)
|
return Response(status=status.INTERNAL_SERVER_ERROR)
|
||||||
|
|
||||||
|
def get(self, request):
|
||||||
|
return Response({})
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
(r'^$', MockView.as_view()),
|
(r'^$', MockView.as_view()),
|
||||||
)
|
)
|
||||||
|
@ -345,3 +349,12 @@ class TestAuthSetter(TestCase):
|
||||||
request = Request(factory.get('/'))
|
request = Request(factory.get('/'))
|
||||||
request.auth = 'DUMMY'
|
request.auth = 'DUMMY'
|
||||||
self.assertEqual(request.auth, 'DUMMY')
|
self.assertEqual(request.auth, 'DUMMY')
|
||||||
|
|
||||||
|
|
||||||
|
class TestQueryString(IETestCase):
|
||||||
|
urls = 'rest_framework.tests.test_request'
|
||||||
|
|
||||||
|
def test_query_string_utf8(self):
|
||||||
|
qs = {'q': u'pølse'}
|
||||||
|
response = self.client.get('/', qs)
|
||||||
|
self.assertEqual(status.HTTP_200_OK, response.status_code)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user