diff options
Diffstat (limited to 'tests/admin_views')
| -rw-r--r-- | tests/admin_views/models.py | 2 | ||||
| -rw-r--r-- | tests/admin_views/tests.py | 26 |
2 files changed, 24 insertions, 4 deletions
diff --git a/tests/admin_views/models.py b/tests/admin_views/models.py index 5cc6f6251a..5ec4fbb544 100644 --- a/tests/admin_views/models.py +++ b/tests/admin_views/models.py @@ -137,7 +137,7 @@ class Thing(models.Model): class Actor(models.Model): name = models.CharField(max_length=50) age = models.IntegerField() - title = models.CharField(max_length=50, null=True) + title = models.CharField(max_length=50, null=True, blank=True) def __str__(self): return self.name diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 528c728069..235fe0cb54 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -57,7 +57,7 @@ for a staff account. Note that both fields may be case-sensitive." @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) -class AdminViewBasicTest(TestCase): +class AdminViewBasicTestCase(TestCase): fixtures = ['admin-views-users.xml', 'admin-views-colors.xml', 'admin-views-fabrics.xml', 'admin-views-books.xml'] @@ -92,6 +92,7 @@ class AdminViewBasicTest(TestCase): failing_msg ) +class AdminViewBasicTest(AdminViewBasicTestCase): def testTrailingSlashRequired(self): """ If you leave off the trailing slash, app should redirect and add it. @@ -583,6 +584,14 @@ class AdminViewBasicTest(TestCase): response = self.client.get("/test_admin/admin/admin_views/inquisition/?leader__name=Palin&leader__age=27") self.assertEqual(response.status_code, 200) + def test_popup_dismiss_related(self): + """ + Regression test for ticket 20664 - ensure the pk is properly quoted. + """ + actor = Actor.objects.create(name="Palin", age=27) + response = self.client.get("/test_admin/admin/admin_views/actor/?%s" % IS_POPUP_VAR) + self.assertContains(response, "opener.dismissRelatedLookupPopup(window, '%s')" % actor.pk) + def test_hide_change_password(self): """ Tests if the "change password" link in the admin is hidden if the User @@ -753,7 +762,7 @@ class SaveAsTests(TestCase): self.assertEqual(response.context['form_url'], '/test_admin/admin/admin_views/person/add/') -class CustomModelAdminTest(AdminViewBasicTest): +class CustomModelAdminTest(AdminViewBasicTestCase): urls = "admin_views.urls" urlbit = "admin2" @@ -2554,6 +2563,17 @@ action)</option> '/test_admin/admin/admin_views/subscriber/?%s' % IS_POPUP_VAR) self.assertEqual(response.context["action_form"], None) + def test_popup_template_response(self): + """ + Success on popups shall be rendered from template in order to allow + easy customization. + """ + response = self.client.post( + '/test_admin/admin/admin_views/actor/add/?%s=1' % IS_POPUP_VAR, + {'name': 'Troy McClure', 'age': '55', IS_POPUP_VAR: '1'}) + self.assertEqual(response.status_code, 200) + self.assertEqual(response.template_name, 'admin/popup_response.html') + @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class TestCustomChangeList(TestCase): @@ -4275,7 +4295,7 @@ class AdminKeepChangeListFiltersTests(TestCase): # Get the `add_view`. response = self.client.get(self.get_add_url()) self.assertEqual(response.status_code, 200) - + # Check the form action. form_action = """<form enctype="multipart/form-data" action="?%s" method="post" id="user_form">""" % self.get_preserved_filters_querystring() self.assertContains(response, form_action, count=1) |
