django-rest-framework/tests/test_reverse.py

29 lines
688 B
Python
Raw Normal View History

from __future__ import unicode_literals
2013-09-25 13:30:04 +04:00
from django.conf.urls import patterns, url
from django.test import TestCase
from rest_framework.reverse import reverse
2013-06-28 20:17:39 +04:00
from rest_framework.test import APIRequestFactory
2013-06-28 20:17:39 +04:00
factory = APIRequestFactory()
2012-09-28 19:09:52 +04:00
def null_view(request):
pass
2014-08-19 16:28:07 +04:00
urlpatterns = patterns(
'',
2012-09-28 19:09:52 +04:00
url(r'^view$', null_view, name='view'),
)
class ReverseTests(TestCase):
"""
2013-02-25 17:48:21 +04:00
Tests for fully qualified URLs when using `reverse`.
"""
urls = 'tests.test_reverse'
def test_reversed_urls_are_fully_qualified(self):
2012-09-28 19:09:52 +04:00
request = factory.get('/view')
url = reverse('view', request=request)
self.assertEqual(url, 'http://testserver/view')