aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/tests/accept.py
diff options
context:
space:
mode:
authortom christie tom@tomchristie.com2011-02-19 10:26:27 +0000
committertom christie tom@tomchristie.com2011-02-19 10:26:27 +0000
commit805aa03ec1871f6a766d9052b348ddce9e9843c3 (patch)
tree8ab5b6a7396236aa45bbc61e8404cc77fc75a9c5 /djangorestframework/tests/accept.py
parentb749b950a1b4bede76b7e3900a6385779904902d (diff)
downloaddjango-rest-framework-805aa03ec1871f6a766d9052b348ddce9e9843c3.tar.bz2
Yowzers. Final big bunch of refactoring for 0.1 release. Now support Django 1.3's views, admin style api is all polished off, loads of tests, new test project for running the test. All sorts of goodness. Getting ready to push this out now.
Diffstat (limited to 'djangorestframework/tests/accept.py')
-rw-r--r--djangorestframework/tests/accept.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/djangorestframework/tests/accept.py b/djangorestframework/tests/accept.py
index c4964e8a..f2a21277 100644
--- a/djangorestframework/tests/accept.py
+++ b/djangorestframework/tests/accept.py
@@ -1,5 +1,5 @@
from django.test import TestCase
-from djangorestframework.tests.utils import RequestFactory
+from djangorestframework.compat import RequestFactory
from djangorestframework.resource import Resource
@@ -24,6 +24,7 @@ class UserAgentMungingTest(TestCase):
return {'a':1, 'b':2, 'c':3}
self.req = RequestFactory()
self.MockResource = MockResource
+ self.view = MockResource.as_view()
def test_munge_msie_accept_header(self):
"""Send MSIE user agent strings and ensure that we get an HTML response,
@@ -32,19 +33,19 @@ class UserAgentMungingTest(TestCase):
MSIE_8_USER_AGENT,
MSIE_7_USER_AGENT):
req = self.req.get('/', HTTP_ACCEPT='*/*', HTTP_USER_AGENT=user_agent)
- resp = self.MockResource(req)
+ resp = self.view(req)
self.assertEqual(resp['Content-Type'], 'text/html')
- def test_dont_munge_msie_accept_header(self):
- """Turn off _MUNGE_IE_ACCEPT_HEADER, send MSIE user agent strings and ensure
+ def test_dont_rewrite_msie_accept_header(self):
+ """Turn off REWRITE_IE_ACCEPT_HEADER, send MSIE user agent strings and ensure
that we get a JSON response if we set a */* accept header."""
- self.MockResource._MUNGE_IE_ACCEPT_HEADER = False
+ view = self.MockResource.as_view(REWRITE_IE_ACCEPT_HEADER=False)
for user_agent in (MSIE_9_USER_AGENT,
MSIE_8_USER_AGENT,
MSIE_7_USER_AGENT):
req = self.req.get('/', HTTP_ACCEPT='*/*', HTTP_USER_AGENT=user_agent)
- resp = self.MockResource(req)
+ resp = view(req)
self.assertEqual(resp['Content-Type'], 'application/json')
def test_dont_munge_nice_browsers_accept_header(self):
@@ -56,7 +57,7 @@ class UserAgentMungingTest(TestCase):
OPERA_11_0_MSIE_USER_AGENT,
OPERA_11_0_OPERA_USER_AGENT):
req = self.req.get('/', HTTP_ACCEPT='*/*', HTTP_USER_AGENT=user_agent)
- resp = self.MockResource(req)
+ resp = self.view(req)
self.assertEqual(resp['Content-Type'], 'application/json')