From 46c8df640cfed5dd525ac1bcf5ad7e57b7ff2571 Mon Sep 17 00:00:00 2001 From: Siburg Date: Mon, 23 Nov 2020 17:37:53 +1300 Subject: Fixed #32219 -- Made InlineModelAdmin.verbose_name_plural fallback to its verbose_name. --- tests/admin_inlines/tests.py | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'tests') diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py index 261c4f0148..c96853a7ff 100644 --- a/tests/admin_inlines/tests.py +++ b/tests/admin_inlines/tests.py @@ -967,6 +967,55 @@ class TestReadOnlyChangeViewInlinePermissions(TestCase): class TestVerboseNameInlineForms(TestDataMixin, TestCase): factory = RequestFactory() + def test_verbose_name_inline(self): + class NonVerboseProfileInline(TabularInline): + model = Profile + verbose_name = 'Non-verbose childs' + + class VerboseNameProfileInline(TabularInline): + model = VerboseNameProfile + verbose_name = 'Childs with verbose name' + + class VerboseNamePluralProfileInline(TabularInline): + model = VerboseNamePluralProfile + verbose_name = 'Childs with verbose name plural' + + class BothVerboseNameProfileInline(TabularInline): + model = BothVerboseNameProfile + verbose_name = 'Childs with both verbose names' + + modeladmin = ModelAdmin(ProfileCollection, admin_site) + modeladmin.inlines = [ + NonVerboseProfileInline, + VerboseNameProfileInline, + VerboseNamePluralProfileInline, + BothVerboseNameProfileInline, + ] + obj = ProfileCollection.objects.create() + url = reverse('admin:admin_inlines_profilecollection_change', args=(obj.pk,)) + request = self.factory.get(url) + request.user = self.superuser + response = modeladmin.changeform_view(request) + self.assertNotContains(response, 'Add another Profile') + # Non-verbose model. + self.assertContains(response, '

Non-verbose childss

') + self.assertContains(response, 'Add another Non-verbose child') + self.assertNotContains(response, '

Profiles

') + # Model with verbose name. + self.assertContains(response, '

Childs with verbose names

') + self.assertContains(response, 'Add another Childs with verbose name') + self.assertNotContains(response, '

Model with verbose name onlys

') + self.assertNotContains(response, 'Add another Model with verbose name only') + # Model with verbose name plural. + self.assertContains(response, '

Childs with verbose name plurals

') + self.assertContains(response, 'Add another Childs with verbose name plural') + self.assertNotContains(response, '

Model with verbose name plural only

') + # Model with both verbose names. + self.assertContains(response, '

Childs with both verbose namess

') + self.assertContains(response, 'Add another Childs with both verbose names') + self.assertNotContains(response, '

Model with both - plural name

') + self.assertNotContains(response, 'Add another Model with both - name') + def test_verbose_name_plural_inline(self): class NonVerboseProfileInline(TabularInline): model = Profile -- cgit v1.3