aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/tests/reverse.py
blob: 63e2080a2e884efd7e92ebe00f44146ac5190760 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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.resource import Resource

<<<<<<< local

=======
>>>>>>> other

class MockResource(Resource):
    """Mock resource which simply returns a URL, so that we can ensure that reversed URLs are fully qualified"""
    permissions = ()

    def get(self, request):
        return reverse('another')

urlpatterns = patterns('',
    url(r'^$', MockResource.as_view()),
    url(r'^another$', MockResource.as_view(), name='another'),
)


class ReverseTests(TestCase):
    """Tests for """
    urls = 'djangorestframework.tests.reverse'

    def test_reversed_urls_are_fully_qualified(self):
        try:
            response = self.client.get('/')
        except:
            import traceback
            traceback.print_exc()
        self.assertEqual(json.loads(response.content), 'http://testserver/another')