Corrected admin_views tests following removal of the email fallback on admin logins.
This commit is contained in:
parent
20d1892491
commit
2c5e833a30
|
@ -52,6 +52,7 @@ from .models import (Article, BarAccount, CustomArticle, EmptyModel, FooAccount,
|
||||||
ERROR_MESSAGE = "Please enter the correct username and password \
|
ERROR_MESSAGE = "Please enter the correct username and password \
|
||||||
for a staff account. Note that both fields are case-sensitive."
|
for a staff account. Note that both fields are case-sensitive."
|
||||||
|
|
||||||
|
|
||||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||||
class AdminViewBasicTest(TestCase):
|
class AdminViewBasicTest(TestCase):
|
||||||
fixtures = ['admin-views-users.xml', 'admin-views-colors.xml',
|
fixtures = ['admin-views-users.xml', 'admin-views-colors.xml',
|
||||||
|
@ -578,6 +579,7 @@ class AdminViewBasicTest(TestCase):
|
||||||
(self.urlbit, instance.pk))
|
(self.urlbit, instance.pk))
|
||||||
self.assertNotContains(response, 'deletelink')
|
self.assertNotContains(response, 'deletelink')
|
||||||
|
|
||||||
|
|
||||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||||
class AdminViewFormUrlTest(TestCase):
|
class AdminViewFormUrlTest(TestCase):
|
||||||
urls = "regressiontests.admin_views.urls"
|
urls = "regressiontests.admin_views.urls"
|
||||||
|
@ -643,7 +645,6 @@ class AdminJavaScriptTest(TestCase):
|
||||||
'<script type="text/javascript">document.getElementById("id_start_date_0").focus();</script>'
|
'<script type="text/javascript">document.getElementById("id_start_date_0").focus();</script>'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_js_minified_only_if_debug_is_false(self):
|
def test_js_minified_only_if_debug_is_false(self):
|
||||||
"""
|
"""
|
||||||
Ensure that the minified versions of the JS files are only used when
|
Ensure that the minified versions of the JS files are only used when
|
||||||
|
@ -708,6 +709,7 @@ class SaveAsTests(TestCase):
|
||||||
response = self.client.post('/test_admin/admin/admin_views/person/1/', post_data)
|
response = self.client.post('/test_admin/admin/admin_views/person/1/', post_data)
|
||||||
self.assertEqual(response.context['form_url'], '/test_admin/admin/admin_views/person/add/')
|
self.assertEqual(response.context['form_url'], '/test_admin/admin/admin_views/person/add/')
|
||||||
|
|
||||||
|
|
||||||
class CustomModelAdminTest(AdminViewBasicTest):
|
class CustomModelAdminTest(AdminViewBasicTest):
|
||||||
urls = "regressiontests.admin_views.urls"
|
urls = "regressiontests.admin_views.urls"
|
||||||
urlbit = "admin2"
|
urlbit = "admin2"
|
||||||
|
@ -763,11 +765,13 @@ class CustomModelAdminTest(AdminViewBasicTest):
|
||||||
response = self.client.get('/test_admin/%s/my_view/' % self.urlbit)
|
response = self.client.get('/test_admin/%s/my_view/' % self.urlbit)
|
||||||
self.assertEqual(response.content, b"Django is a magical pony!")
|
self.assertEqual(response.content, b"Django is a magical pony!")
|
||||||
|
|
||||||
|
|
||||||
def get_perm(Model, perm):
|
def get_perm(Model, perm):
|
||||||
"""Return the permission object, for the Model"""
|
"""Return the permission object, for the Model"""
|
||||||
ct = ContentType.objects.get_for_model(Model)
|
ct = ContentType.objects.get_for_model(Model)
|
||||||
return Permission.objects.get(content_type=ct, codename=perm)
|
return Permission.objects.get(content_type=ct, codename=perm)
|
||||||
|
|
||||||
|
|
||||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||||
class AdminViewPermissionsTest(TestCase):
|
class AdminViewPermissionsTest(TestCase):
|
||||||
"""Tests for Admin Views Permissions."""
|
"""Tests for Admin Views Permissions."""
|
||||||
|
@ -870,7 +874,7 @@ class AdminViewPermissionsTest(TestCase):
|
||||||
response = self.client.get('/test_admin/admin/')
|
response = self.client.get('/test_admin/admin/')
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
login = self.client.post('/test_admin/admin/', self.super_email_login)
|
login = self.client.post('/test_admin/admin/', self.super_email_login)
|
||||||
self.assertContains(login, "Your e-mail address is not your username")
|
self.assertContains(login, ERROR_MESSAGE)
|
||||||
# only correct passwords get a username hint
|
# only correct passwords get a username hint
|
||||||
login = self.client.post('/test_admin/admin/', self.super_email_bad_login)
|
login = self.client.post('/test_admin/admin/', self.super_email_bad_login)
|
||||||
self.assertContains(login, ERROR_MESSAGE)
|
self.assertContains(login, ERROR_MESSAGE)
|
||||||
|
@ -1318,6 +1322,7 @@ class AdminViewDeletedObjectsTest(TestCase):
|
||||||
response = self.client.get('/test_admin/admin/admin_views/plot/%s/delete/' % quote(3))
|
response = self.client.get('/test_admin/admin/admin_views/plot/%s/delete/' % quote(3))
|
||||||
self.assertContains(response, should_contain)
|
self.assertContains(response, should_contain)
|
||||||
|
|
||||||
|
|
||||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||||
class AdminViewStringPrimaryKeyTest(TestCase):
|
class AdminViewStringPrimaryKeyTest(TestCase):
|
||||||
urls = "regressiontests.admin_views.urls"
|
urls = "regressiontests.admin_views.urls"
|
||||||
|
@ -1513,7 +1518,7 @@ class SecureViewTests(TestCase):
|
||||||
response = self.client.get('/test_admin/admin/secure-view/')
|
response = self.client.get('/test_admin/admin/secure-view/')
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
login = self.client.post('/test_admin/admin/secure-view/', self.super_email_login)
|
login = self.client.post('/test_admin/admin/secure-view/', self.super_email_login)
|
||||||
self.assertContains(login, "Your e-mail address is not your username")
|
self.assertContains(login, ERROR_MESSAGE)
|
||||||
# only correct passwords get a username hint
|
# only correct passwords get a username hint
|
||||||
login = self.client.post('/test_admin/admin/secure-view/', self.super_email_bad_login)
|
login = self.client.post('/test_admin/admin/secure-view/', self.super_email_bad_login)
|
||||||
self.assertContains(login, ERROR_MESSAGE)
|
self.assertContains(login, ERROR_MESSAGE)
|
||||||
|
@ -1583,6 +1588,7 @@ class SecureViewTests(TestCase):
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
self.assertEqual(response['Location'], 'http://example.com/users/super/')
|
self.assertEqual(response['Location'], 'http://example.com/users/super/')
|
||||||
|
|
||||||
|
|
||||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||||
class AdminViewUnicodeTest(TestCase):
|
class AdminViewUnicodeTest(TestCase):
|
||||||
urls = "regressiontests.admin_views.urls"
|
urls = "regressiontests.admin_views.urls"
|
||||||
|
@ -2064,7 +2070,7 @@ class AdminSearchTest(TestCase):
|
||||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||||
class AdminInheritedInlinesTest(TestCase):
|
class AdminInheritedInlinesTest(TestCase):
|
||||||
urls = "regressiontests.admin_views.urls"
|
urls = "regressiontests.admin_views.urls"
|
||||||
fixtures = ['admin-views-users.xml',]
|
fixtures = ['admin-views-users.xml']
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.client.login(username='super', password='secret')
|
self.client.login(username='super', password='secret')
|
||||||
|
@ -2148,6 +2154,7 @@ class AdminInheritedInlinesTest(TestCase):
|
||||||
self.assertEqual(BarAccount.objects.all()[0].username, "%s-1" % bar_user)
|
self.assertEqual(BarAccount.objects.all()[0].username, "%s-1" % bar_user)
|
||||||
self.assertEqual(Persona.objects.all()[0].accounts.count(), 2)
|
self.assertEqual(Persona.objects.all()[0].accounts.count(), 2)
|
||||||
|
|
||||||
|
|
||||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||||
class AdminActionsTest(TestCase):
|
class AdminActionsTest(TestCase):
|
||||||
urls = "regressiontests.admin_views.urls"
|
urls = "regressiontests.admin_views.urls"
|
||||||
|
@ -2415,6 +2422,7 @@ class TestInlineNotEditable(TestCase):
|
||||||
response = self.client.get('/test_admin/admin/admin_views/parent/add/')
|
response = self.client.get('/test_admin/admin/admin_views/parent/add/')
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
|
||||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||||
class AdminCustomQuerysetTest(TestCase):
|
class AdminCustomQuerysetTest(TestCase):
|
||||||
urls = "regressiontests.admin_views.urls"
|
urls = "regressiontests.admin_views.urls"
|
||||||
|
@ -2471,6 +2479,7 @@ class AdminCustomQuerysetTest(TestCase):
|
||||||
# Message should contain non-ugly model name. Instance representation is set by model's __unicode__()
|
# Message should contain non-ugly model name. Instance representation is set by model's __unicode__()
|
||||||
self.assertContains(response, '<li class="info">The cover letter "John Doe II" was changed successfully.</li>', html=True)
|
self.assertContains(response, '<li class="info">The cover letter "John Doe II" was changed successfully.</li>', html=True)
|
||||||
|
|
||||||
|
|
||||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||||
class AdminInlineFileUploadTest(TestCase):
|
class AdminInlineFileUploadTest(TestCase):
|
||||||
urls = "regressiontests.admin_views.urls"
|
urls = "regressiontests.admin_views.urls"
|
||||||
|
@ -3067,6 +3076,7 @@ class SeleniumPrePopulatedFirefoxTests(AdminSeleniumWebDriverTestCase):
|
||||||
class SeleniumPrePopulatedChromeTests(SeleniumPrePopulatedFirefoxTests):
|
class SeleniumPrePopulatedChromeTests(SeleniumPrePopulatedFirefoxTests):
|
||||||
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
|
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
|
||||||
|
|
||||||
|
|
||||||
class SeleniumPrePopulatedIETests(SeleniumPrePopulatedFirefoxTests):
|
class SeleniumPrePopulatedIETests(SeleniumPrePopulatedFirefoxTests):
|
||||||
webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
|
webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
|
||||||
|
|
||||||
|
@ -3179,6 +3189,7 @@ class RawIdFieldsTest(TestCase):
|
||||||
self.assertContains(response2, "Spain")
|
self.assertContains(response2, "Spain")
|
||||||
self.assertNotContains(response2, "England")
|
self.assertNotContains(response2, "England")
|
||||||
|
|
||||||
|
|
||||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||||
class UserAdminTest(TestCase):
|
class UserAdminTest(TestCase):
|
||||||
"""
|
"""
|
||||||
|
@ -3345,6 +3356,7 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
docutils = None
|
docutils = None
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(docutils, "no docutils installed.")
|
@unittest.skipUnless(docutils, "no docutils installed.")
|
||||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||||
class AdminDocsTest(TestCase):
|
class AdminDocsTest(TestCase):
|
||||||
|
@ -3540,6 +3552,7 @@ class DateHierarchyTests(TestCase):
|
||||||
self.assert_non_localized_year(response, 2003)
|
self.assert_non_localized_year(response, 2003)
|
||||||
self.assert_non_localized_year(response, 2005)
|
self.assert_non_localized_year(response, 2005)
|
||||||
|
|
||||||
|
|
||||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||||
class AdminCustomSaveRelatedTests(TestCase):
|
class AdminCustomSaveRelatedTests(TestCase):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue