aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/tests
diff options
context:
space:
mode:
authorSébastien Piquemal2012-02-23 09:01:33 +0200
committerSébastien Piquemal2012-02-23 09:01:33 +0200
commit9da1ae81dc9a056db94ea07f35478ed003fea598 (patch)
tree2557ce0fe8be2b7febb184c3bb3da7b5289fbbe1 /djangorestframework/tests
parent242327d339fe1193a45c64cb20a2ba4c56044c3b (diff)
parent5fd4c639d7c64572dd07dc31dcd627bed9469b05 (diff)
downloaddjango-rest-framework-9da1ae81dc9a056db94ea07f35478ed003fea598.tar.bz2
merged + fixed broken test
Diffstat (limited to 'djangorestframework/tests')
-rw-r--r--djangorestframework/tests/reverse.py25
-rw-r--r--djangorestframework/tests/views.py14
2 files changed, 15 insertions, 24 deletions
diff --git a/djangorestframework/tests/reverse.py b/djangorestframework/tests/reverse.py
index c49caca0..56e1ed5b 100644
--- a/djangorestframework/tests/reverse.py
+++ b/djangorestframework/tests/reverse.py
@@ -1,29 +1,34 @@
from django.conf.urls.defaults import patterns, url
-from django.core.urlresolvers import reverse
from django.test import TestCase
from django.utils import simplejson as json
+from djangorestframework.renderers import JSONRenderer
+from djangorestframework.reverse import reverse
from djangorestframework.views import View
from djangorestframework.response import Response
-class MockView(View):
- """Mock resource which simply returns a URL, so that we can ensure that reversed URLs are fully qualified"""
- permissions = ()
+class MyView(View):
+ """
+ Mock resource which simply returns a URL, so that we can ensure
+ that reversed URLs are fully qualified.
+ """
+ renderers = (JSONRenderer, )
def get(self, request):
- return Response(reverse('another'))
+ return Response(reverse('myview', request))
urlpatterns = patterns('',
- url(r'^$', MockView.as_view()),
- url(r'^another$', MockView.as_view(), name='another'),
+ url(r'^myview$', MyView.as_view(), name='myview'),
)
class ReverseTests(TestCase):
- """Tests for """
+ """
+ Tests for fully qualifed URLs when using `reverse`.
+ """
urls = 'djangorestframework.tests.reverse'
def test_reversed_urls_are_fully_qualified(self):
- response = self.client.get('/')
- self.assertEqual(json.loads(response.content), 'http://testserver/another')
+ response = self.client.get('/myview')
+ self.assertEqual(json.loads(response.content), 'http://testserver/myview')
diff --git a/djangorestframework/tests/views.py b/djangorestframework/tests/views.py
index ab5d75d6..d4189087 100644
--- a/djangorestframework/tests/views.py
+++ b/djangorestframework/tests/views.py
@@ -46,8 +46,6 @@ class MockResource(ModelResource):
fields = ('foo', 'bar', 'baz')
urlpatterns = patterns('djangorestframework.utils.staticviews',
- url(r'^robots.txt$', 'deny_robots'),
- url(r'^favicon.ico$', 'favicon'),
url(r'^accounts/login$', 'api_login'),
url(r'^accounts/logout$', 'api_logout'),
url(r'^mock/$', MockView.as_view()),
@@ -123,18 +121,6 @@ class ExtraViewsTests(TestCase):
"""Test the extra views djangorestframework provides"""
urls = 'djangorestframework.tests.views'
- def test_robots_view(self):
- """Ensure the robots view exists"""
- response = self.client.get('/robots.txt')
- self.assertEqual(response.status_code, 200)
- self.assertEqual(response['Content-Type'], 'text/plain')
-
- def test_favicon_view(self):
- """Ensure the favicon view exists"""
- response = self.client.get('/favicon.ico')
- self.assertEqual(response.status_code, 200)
- self.assertEqual(response['Content-Type'], 'image/vnd.microsoft.icon')
-
def test_login_view(self):
"""Ensure the login view exists"""
response = self.client.get('/accounts/login')