summaryrefslogtreecommitdiff
path: root/tests/admin_docs
diff options
context:
space:
mode:
authorBouke Haarsma <bouke@webatoom.nl>2013-11-05 10:16:27 +0100
committerClaude Paroz <claude@2xlibre.net>2013-12-18 19:44:04 +0100
commita39d672ec7d53637805a61b45a51bc0e7d297a36 (patch)
treea8d9d2e2ff79822a3fbeb01a7974ef0669912ce2 /tests/admin_docs
parentf1b3ab9c2158f5a7da113aef4158499ce2d42ee2 (diff)
Fixed #21386 -- Removed admindocs dependence on sites framework
* Removed ADMIN_FOR setting and warn warning * Group view functions by namespace instead of site * Added a test verifying namespaces are listed Thanks to Claude Paroz for reviewing and ideas for improvement.
Diffstat (limited to 'tests/admin_docs')
-rw-r--r--tests/admin_docs/tests.py31
-rw-r--r--tests/admin_docs/urls.py7
2 files changed, 37 insertions, 1 deletions
diff --git a/tests/admin_docs/tests.py b/tests/admin_docs/tests.py
index 0d4bcbd998..047bf920a2 100644
--- a/tests/admin_docs/tests.py
+++ b/tests/admin_docs/tests.py
@@ -1,5 +1,7 @@
import unittest
+from django.conf import settings
+from django.contrib.sites.models import Site
from django.contrib.admindocs import utils
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
@@ -7,6 +9,33 @@ from django.test import TestCase
from django.test.utils import override_settings
+class MiscTests(TestCase):
+ urls = 'admin_docs.urls'
+
+ def setUp(self):
+ self._old_installed = Site._meta.app_config.installed
+ User.objects.create_superuser('super', None, 'secret')
+ self.client.login(username='super', password='secret')
+
+ def tearDown(self):
+ Site._meta.app_config.installed = self._old_installed
+
+ @override_settings(
+ SITE_ID=None,
+ INSTALLED_APPS=[app for app in settings.INSTALLED_APPS
+ if app != 'django.contrib.sites'],
+ )
+ def test_no_sites_framework(self):
+ """
+ Without the sites framework, should not access SITE_ID or Site
+ objects. Deleting settings is fine here as UserSettingsHolder is used.
+ """
+ Site._meta.app_config.installed = False
+ Site.objects.all().delete()
+ del settings.SITE_ID
+ self.client.get('/admindocs/views/') # should not raise
+
+
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
@unittest.skipUnless(utils.docutils_is_available, "no docutils installed.")
class AdminDocViewTests(TestCase):
@@ -46,6 +75,8 @@ class AdminDocViewTests(TestCase):
self.assertContains(response,
'<h3><a href="/admindocs/views/django.contrib.admindocs.views.BaseAdminDocsView/">/admindocs/</a></h3>',
html=True)
+ self.assertContains(response, 'Views by namespace test')
+ self.assertContains(response, 'Name: <code>test:func</code>.')
def test_view_detail(self):
response = self.client.get(
diff --git a/tests/admin_docs/urls.py b/tests/admin_docs/urls.py
index 2dcd0315be..48e7898d09 100644
--- a/tests/admin_docs/urls.py
+++ b/tests/admin_docs/urls.py
@@ -1,11 +1,16 @@
-from django.conf.urls import include, patterns
+from django.conf.urls import include, patterns, url
from django.contrib import admin
from . import views
+ns_patterns = patterns('',
+ url(r'^xview/func/$', views.xview_dec(views.xview), name='func'),
+)
+
urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
(r'^admindocs/', include('django.contrib.admindocs.urls')),
+ (r'^', include(ns_patterns, namespace='test')),
(r'^xview/func/$', views.xview_dec(views.xview)),
(r'^xview/class/$', views.xview_dec(views.XViewClass.as_view())),
)