Test showing behaviour of issue #1586 given Python3 and Internet Explorer behaviour on query strings

This commit is contained in:
Henrik Ossipoff Hansen 2014-05-19 12:59:13 +02:00
parent 5c12b07681
commit 6c0624631e
2 changed files with 28 additions and 1 deletions

View File

@ -9,6 +9,7 @@ from django.test.client import Client as DjangoClient
from django.test.client import ClientHandler
from django.test import testcases
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.compat import RequestFactory as DjangoRequestFactory
from rest_framework.compat import force_bytes_or_smart_bytes, six
@ -169,3 +170,16 @@ if django.VERSION >= (1, 4):
class APILiveServerTestCase(testcases.LiveServerTestCase):
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

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
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.response import Response
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.compat import six
from io import BytesIO
@ -272,6 +273,9 @@ class MockView(APIView):
return Response(status=status.INTERNAL_SERVER_ERROR)
def get(self, request):
return Response({})
urlpatterns = patterns('',
(r'^$', MockView.as_view()),
)
@ -345,3 +349,12 @@ class TestAuthSetter(TestCase):
request = Request(factory.get('/'))
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)