diff options
| author | tom christie tom@tomchristie.com | 2011-02-19 10:26:27 +0000 |
|---|---|---|
| committer | tom christie tom@tomchristie.com | 2011-02-19 10:26:27 +0000 |
| commit | 805aa03ec1871f6a766d9052b348ddce9e9843c3 (patch) | |
| tree | 8ab5b6a7396236aa45bbc61e8404cc77fc75a9c5 /djangorestframework/tests/reverse.py | |
| parent | b749b950a1b4bede76b7e3900a6385779904902d (diff) | |
| download | django-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/reverse.py')
| -rw-r--r-- | djangorestframework/tests/reverse.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/djangorestframework/tests/reverse.py b/djangorestframework/tests/reverse.py new file mode 100644 index 00000000..a862e39a --- /dev/null +++ b/djangorestframework/tests/reverse.py @@ -0,0 +1,32 @@ +from django.conf.urls.defaults import patterns, url +from django.core.urlresolvers import reverse +from django.test import TestCase + +from djangorestframework.resource import Resource + +try: + import json +except ImportError: + import simplejson as json + + +class MockResource(Resource): + """Mock resource which simply returns a URL, so that we can ensure that reversed URLs are fully qualified""" + anon_allowed_methods = ('GET',) + + def get(self, request, auth): + 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): + response = self.client.get('/') + self.assertEqual(json.loads(response.content), 'http://testserver/another') |
