Ticket #12893: test12893.patch
File test12893.patch, 1.8 KB (added by , 14 years ago) |
---|
-
tests/regressiontests/admin_changelist/tests.py
diff --git a/tests/regressiontests/admin_changelist/tests.py b/tests/regressiontests/admin_changelist/tests.py index c8ad1ce..7c14d28 100644
a b class ChangeListTests(TransactionTestCase): 71 71 self.failIf('<td>%s</td>' % editable_name_field == -1, 72 72 'Failed to find "name" list_editable field in: %s' % table_output) 73 73 74 def test_pagination_queryset(self): 75 """ 76 Regression tests for #12893: Pagination in admins changelist doesn't 77 use queryset set by modeladmin 78 """ 79 parent = Parent.objects.create(name='anything') 80 for i in range(200): 81 Child.objects.create(name='name %s' % i, parent=parent) 82 Child.objects.create(name='filtered %s' % i, parent=parent) 83 84 request = MockRequest() 85 m = FilteredChildAdmin(Child, admin.site) 86 cl = ChangeList(request, Child, m.list_display, m.list_display_links, 87 m.list_filter, m.date_hierarchy, m.search_fields, 88 m.list_select_related, m.list_per_page, m.list_editable, m) 89 90 self.assertEqual(cl.query_set.count(), 200) 91 self.assertEqual(cl.paginator.count, 200) 92 self.assertEqual(cl.paginator.page_range, [1, 2]) 93 94 74 95 class ChildAdmin(admin.ModelAdmin): 75 96 list_display = ['name', 'parent'] 76 97 def queryset(self, request): 77 98 return super(ChildAdmin, self).queryset(request).select_related("parent__name") 78 99 100 class FilteredChildAdmin(admin.ModelAdmin): 101 list_display = ['name', 'parent'] 102 def queryset(self, request): 103 return super(FilteredChildAdmin, self).queryset(request).filter( 104 name__contains='filtered') 105 79 106 class MockRequest(object): 80 107 GET = {}