'Regression tests for ticket #17646: dynamic list_filter support.'

def test_dynamic_list_filter(self):

    parent = Parent.objects.create(name=u'parent')
    for i in range(10):
        Child.objects.create(name=(u'child    %s' % i), parent=parent)
    user_noparents = self._create_superuser(u'noparents')
    user_parents = self._create_superuser(u'parents')
    m = DynamicListFilterChildAdmin(Child, admin.site)
    request = self._mocked_authenticated_request(u'/child/', user_noparents)
    response = m.changelist_view(request)
    self.assertEqual(response.context_data[u'cl'].list_filter, [u'name', u'age'])
    m = DynamicListFilterChildAdmin(Child, admin.site)
    request = self._mocked_authenticated_request(u'/child/', user_parents)
    response = m.changelist_view(request)
    self.assertEqual(response.context_data[u'cl'].list_filter, (u'parent', u'name', u'age'))
