aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/tests
diff options
context:
space:
mode:
authorTom Christie2011-05-10 10:49:28 +0100
committerTom Christie2011-05-10 10:49:28 +0100
commit8f58ee489d34b200acfc2666816eb32e47c8cef5 (patch)
treee1c4a273b46abd9ad7c74d6837108d31a7b76d9c /djangorestframework/tests
parentd373b3a067796b8e181be9368fa24e89c572c45e (diff)
downloaddjango-rest-framework-8f58ee489d34b200acfc2666816eb32e47c8cef5.tar.bz2
Getting the API into shape
Diffstat (limited to 'djangorestframework/tests')
-rw-r--r--djangorestframework/tests/content.py6
-rw-r--r--djangorestframework/tests/parsers.py11
-rw-r--r--djangorestframework/tests/throttling.py4
3 files changed, 10 insertions, 11 deletions
diff --git a/djangorestframework/tests/content.py b/djangorestframework/tests/content.py
index 6695bf68..e566ea00 100644
--- a/djangorestframework/tests/content.py
+++ b/djangorestframework/tests/content.py
@@ -4,7 +4,7 @@ Tests for content parsing, and form-overloaded content parsing.
from django.test import TestCase
from djangorestframework.compat import RequestFactory
from djangorestframework.mixins import RequestMixin
-from djangorestframework.parsers import FormParser, MultipartParser, PlainTextParser
+from djangorestframework.parsers import FormParser, MultiPartParser, PlainTextParser
class TestContentParsing(TestCase):
@@ -19,7 +19,7 @@ class TestContentParsing(TestCase):
def ensure_determines_form_content_POST(self, view):
"""Ensure view.RAW_CONTENT returns content for POST request with form content."""
form_data = {'qwerty': 'uiop'}
- view.parsers = (FormParser, MultipartParser)
+ view.parsers = (FormParser, MultiPartParser)
view.request = self.req.post('/', data=form_data)
self.assertEqual(view.RAW_CONTENT, form_data)
@@ -34,7 +34,7 @@ class TestContentParsing(TestCase):
def ensure_determines_form_content_PUT(self, view):
"""Ensure view.RAW_CONTENT returns content for PUT request with form content."""
form_data = {'qwerty': 'uiop'}
- view.parsers = (FormParser, MultipartParser)
+ view.parsers = (FormParser, MultiPartParser)
view.request = self.req.put('/', data=form_data)
self.assertEqual(view.RAW_CONTENT, form_data)
diff --git a/djangorestframework/tests/parsers.py b/djangorestframework/tests/parsers.py
index 049ac741..88aad880 100644
--- a/djangorestframework/tests/parsers.py
+++ b/djangorestframework/tests/parsers.py
@@ -39,7 +39,7 @@ This new parser only flattens the lists of parameters that contain a single valu
>>> MyFormParser(some_view).parse(StringIO(inpt)) == {'key1': 'bla1', 'key2': ['blo1', 'blo2']}
True
-.. note:: The same functionality is available for :class:`parsers.MultipartParser`.
+.. note:: The same functionality is available for :class:`parsers.MultiPartParser`.
Submitting an empty list
--------------------------
@@ -80,9 +80,8 @@ import httplib, mimetypes
from tempfile import TemporaryFile
from django.test import TestCase
from djangorestframework.compat import RequestFactory
-from djangorestframework.parsers import MultipartParser
+from djangorestframework.parsers import MultiPartParser
from djangorestframework.views import BaseView
-from djangorestframework.utils.mediatypes import MediaType
from StringIO import StringIO
def encode_multipart_formdata(fields, files):
@@ -113,18 +112,18 @@ def encode_multipart_formdata(fields, files):
def get_content_type(filename):
return mimetypes.guess_type(filename)[0] or 'application/octet-stream'
-class TestMultipartParser(TestCase):
+class TestMultiPartParser(TestCase):
def setUp(self):
self.req = RequestFactory()
self.content_type, self.body = encode_multipart_formdata([('key1', 'val1'), ('key1', 'val2')],
[('file1', 'pic.jpg', 'blablabla'), ('file1', 't.txt', 'blobloblo')])
def test_multipartparser(self):
- """Ensure that MultipartParser can parse multipart/form-data that contains a mix of several files and parameters."""
+ """Ensure that MultiPartParser can parse multipart/form-data that contains a mix of several files and parameters."""
post_req = RequestFactory().post('/', self.body, content_type=self.content_type)
view = BaseView()
view.request = post_req
- parsed = MultipartParser(view).parse(StringIO(self.body))
+ parsed = MultiPartParser(view).parse(StringIO(self.body))
self.assertEqual(parsed['key1'], 'val1')
self.assertEqual(parsed.FILES['file1'].read(), 'blablabla')
diff --git a/djangorestframework/tests/throttling.py b/djangorestframework/tests/throttling.py
index 94d01428..e7a054cd 100644
--- a/djangorestframework/tests/throttling.py
+++ b/djangorestframework/tests/throttling.py
@@ -4,11 +4,11 @@ from django.utils import simplejson as json
from djangorestframework.compat import RequestFactory
from djangorestframework.views import BaseView
-from djangorestframework.permissions import Throttling
+from djangorestframework.permissions import PerUserThrottling
class MockView(BaseView):
- permissions = ( Throttling, )
+ permissions = ( PerUserThrottling, )
throttle = (3, 1) # 3 requests per second
def get(self, request):