2012-09-20 16:06:27 +04:00
|
|
|
from django.test import TestCase
|
2012-09-28 19:09:52 +04:00
|
|
|
from django.test.client import RequestFactory
|
2012-12-20 03:12:27 +04:00
|
|
|
from rest_framework.compat import patterns, url
|
2012-09-20 16:06:27 +04:00
|
|
|
from rest_framework.reverse import reverse
|
|
|
|
|
2012-09-28 19:09:52 +04:00
|
|
|
factory = RequestFactory()
|
2012-09-20 16:06:27 +04:00
|
|
|
|
|
|
|
|
2012-09-28 19:09:52 +04:00
|
|
|
def null_view(request):
|
|
|
|
pass
|
2012-09-20 16:06:27 +04:00
|
|
|
|
|
|
|
urlpatterns = patterns('',
|
2012-09-28 19:09:52 +04:00
|
|
|
url(r'^view$', null_view, name='view'),
|
2012-09-20 16:06:27 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class ReverseTests(TestCase):
|
|
|
|
"""
|
|
|
|
Tests for fully qualifed URLs when using `reverse`.
|
|
|
|
"""
|
|
|
|
urls = 'rest_framework.tests.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')
|