mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 04:20:12 +03:00
Merge 73aa12297a
into add1260be4
This commit is contained in:
commit
3fa5682565
|
@ -3,6 +3,10 @@
|
||||||
# Note that we import as `DjangoRequestFactory` and `DjangoClient` in order
|
# Note that we import as `DjangoRequestFactory` and `DjangoClient` in order
|
||||||
# to make it harder for the user to import the wrong thing without realizing.
|
# to make it harder for the user to import the wrong thing without realizing.
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
try:
|
||||||
|
from urllib import unquote
|
||||||
|
except ImportError:
|
||||||
|
from urllib.parse import unquote
|
||||||
import django
|
import django
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.test.client import Client as DjangoClient
|
from django.test.client import Client as DjangoClient
|
||||||
|
@ -169,3 +173,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': 'pølse'}
|
||||||
|
response = self.client.get('/', qs)
|
||||||
|
self.assertEqual(status.HTTP_200_OK, response.status_code)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user