diff options
| author | Bouke Haarsma <bouke@webatoom.nl> | 2013-11-05 10:16:27 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2013-12-18 19:44:04 +0100 |
| commit | a39d672ec7d53637805a61b45a51bc0e7d297a36 (patch) | |
| tree | a8d9d2e2ff79822a3fbeb01a7974ef0669912ce2 /tests/admin_docs/tests.py | |
| parent | f1b3ab9c2158f5a7da113aef4158499ce2d42ee2 (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/tests.py')
| -rw-r--r-- | tests/admin_docs/tests.py | 31 |
1 files changed, 31 insertions, 0 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( |
