diff options
Diffstat (limited to 'tests/regressiontests/admin_views/tests.py')
| -rw-r--r-- | tests/regressiontests/admin_views/tests.py | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py index f4ec63f8ae..f176708366 100644 --- a/tests/regressiontests/admin_views/tests.py +++ b/tests/regressiontests/admin_views/tests.py @@ -37,7 +37,8 @@ from .models import (Article, BarAccount, CustomArticle, EmptyModel, FooAccount, DooHickey, FancyDoodad, Whatsit, Category, Post, Plot, FunkyTag, Chapter, Book, Promo, WorkHour, Employee, Question, Answer, Inquisition, Actor, FoodDelivery, RowLevelChangePermissionModel, Paper, CoverLetter, Story, - OtherStory, ComplexSortedPerson, Parent, Child) + OtherStory, ComplexSortedPerson, Parent, Child, AdminOrderedField, + AdminOrderedModelMethod, AdminOrderedAdminMethod, AdminOrderedCallable) ERROR_MESSAGE = "Please enter the correct username and password \ @@ -354,6 +355,32 @@ class AdminViewBasicTest(TestCase): response.content.index(link % p2.id) < response.content.index(link % p1.id) ) + def testSortIndicatorsAdminOrder(self): + """ + Ensures that the admin shows default sort indicators for all + kinds of 'ordering' fields: field names, method on the model + admin and model itself, and other callables. See #17252. + """ + models = [(AdminOrderedField, 'adminorderedfield' ), + (AdminOrderedModelMethod, 'adminorderedmodelmethod'), + (AdminOrderedAdminMethod, 'adminorderedadminmethod'), + (AdminOrderedCallable, 'adminorderedcallable' )] + for model, url in models: + a1 = model.objects.create(stuff='The Last Item', order=3) + a2 = model.objects.create(stuff='The First Item', order=1) + a3 = model.objects.create(stuff='The Middle Item', order=2) + response = self.client.get('/test_admin/admin/admin_views/%s/' % url, {}) + self.assertEqual(response.status_code, 200) + # Should have 3 columns including action checkbox col. + self.assertContains(response, '<th scope="col"', count=3, msg_prefix=url) + # Check if the correct column was selected. 2 is the index of the + # 'order' column in the model admin's 'list_display' with 0 being + # the implicit 'action_checkbox' and 1 being the column 'stuff'. + self.assertEqual(response.context['cl'].get_ordering_field_columns(), {2: 'asc'}) + # Check order of records. + self.assertTrue(response.content.index('The First Item') < + response.content.index('The Middle Item') < response.content.index('The Last Item')) + def testLimitedFilter(self): """Ensure admin changelist filters do not contain objects excluded via limit_choices_to. This also tests relation-spanning filters (e.g. 'color__value'). @@ -2757,7 +2784,7 @@ class PrePopulatedTest(TestCase): self.assertNotContains(response, "id: '#id_slug'") self.assertNotContains(response, "field['dependency_ids'].push('#id_title');") self.assertNotContains(response, "id: '#id_prepopulatedsubpost_set-0-subslug',") - + @override_settings(USE_THOUSAND_SEPARATOR = True, USE_L10N = True) def test_prepopulated_maxlength_localized(self): """ |
