'Regression tests for #16257: dynamic list_display_links support.'

def test_dynamic_list_display_links(self):

    parent = Parent.objects.create(name=u'parent')
    for i in range(1, 10):
        Child.objects.create(id=i, name=(u'child    %s' % i), parent=parent, age=i)
    m = DynamicListDisplayLinksChildAdmin(Child, admin.site)
    superuser = self._create_superuser(u'superuser')
    request = self._mocked_authenticated_request(u'/child/', superuser)
    response = m.changelist_view(request)
    for i in range(1, 10):
        link = reverse(u'admin:admin_changelist_child_change', args=(i,))
        self.assertContains(response, (u'<a    href="%s">%s</a>' % (link, i)))
    list_display = m.get_list_display(request)
    list_display_links = m.get_list_display_links(request, list_display)
    self.assertEqual(list_display, (u'parent', u'name', u'age'))
    self.assertEqual(list_display_links, [u'age'])
