'Ensure that inline models which inherit from a common parent are correctly handled by admin.'

def testInline(self):

    foo_user = u'foo    username'
    bar_user = u'bar    username'
    name_re = re.compile('name="(.*?)"')
    response = self.client.get('/test_admin/admin/admin_views/persona/add/')
    names = name_re.findall(response.content)
    self.assertEqual(len(names), len(set(names)))
    post_data = {'name': u'Test    Name', 'accounts-TOTAL_FORMS': u'1', 'accounts-INITIAL_FORMS': u'0', 'accounts-MAX_NUM_FORMS': u'0', 'accounts-0-username': foo_user, 'accounts-2-TOTAL_FORMS': u'1', 'accounts-2-INITIAL_FORMS': u'0', 'accounts-2-MAX_NUM_FORMS': u'0', 'accounts-2-0-username': bar_user}
    response = self.client.post('/test_admin/admin/admin_views/persona/add/', post_data)
    self.assertEqual(response.status_code, 302)
    self.assertEqual(Persona.objects.count(), 1)
    self.assertEqual(FooAccount.objects.count(), 1)
    self.assertEqual(BarAccount.objects.count(), 1)
    self.assertEqual(FooAccount.objects.all()[0].username, foo_user)
    self.assertEqual(BarAccount.objects.all()[0].username, bar_user)
    self.assertEqual(Persona.objects.all()[0].accounts.count(), 2)
    response = self.client.get('/test_admin/admin/admin_views/persona/1/')
    names = name_re.findall(response.content)
    self.assertEqual(len(names), len(set(names)))
    post_data = {'name': u'Test    Name', 'accounts-TOTAL_FORMS': '2', 'accounts-INITIAL_FORMS': u'1', 'accounts-MAX_NUM_FORMS': u'0', 'accounts-0-username': ('%s-1' % foo_user), 'accounts-0-account_ptr': '1', 'accounts-0-persona': '1', 'accounts-2-TOTAL_FORMS': u'2', 'accounts-2-INITIAL_FORMS': u'1', 'accounts-2-MAX_NUM_FORMS': u'0', 'accounts-2-0-username': ('%s-1' % bar_user), 'accounts-2-0-account_ptr': '2', 'accounts-2-0-persona': '1'}
    response = self.client.post('/test_admin/admin/admin_views/persona/1/', post_data)
    self.assertEqual(response.status_code, 302)
    self.assertEqual(Persona.objects.count(), 1)
    self.assertEqual(FooAccount.objects.count(), 1)
    self.assertEqual(BarAccount.objects.count(), 1)
    self.assertEqual(FooAccount.objects.all()[0].username, ('%s-1' % foo_user))
    self.assertEqual(BarAccount.objects.all()[0].username, ('%s-1' % bar_user))
    self.assertEqual(Persona.objects.all()[0].accounts.count(), 2)
