'Test add view restricts access and actually adds items.'

def testAddView(self):

    add_dict = {'title': 'D\xc3\xb8m    ikke', 'content': '<p>great    article</p>', 'date_0': '2008-03-18', 'date_1': '10:54:39', 'section': 1}
    self.client.get('/test_admin/admin/')
    self.client.post('/test_admin/admin/', self.changeuser_login)
    self.assertEqual(self.client.session.test_cookie_worked(), False)
    request = self.client.get('/test_admin/admin/admin_views/article/add/')
    self.assertEqual(request.status_code, 403)
    post = self.client.post('/test_admin/admin/admin_views/article/add/', add_dict)
    self.assertEqual(post.status_code, 403)
    self.assertEqual(Article.objects.all().count(), 3)
    self.client.get('/test_admin/admin/logout/')
    self.client.get('/test_admin/admin/')
    self.client.post('/test_admin/admin/', self.adduser_login)
    addpage = self.client.get('/test_admin/admin/admin_views/article/add/')
    self.assertEqual(addpage.status_code, 200)
    change_list_link = '<a    href="../">Articles</a>    &rsaquo;'
    self.assertFalse((change_list_link in addpage.content), 'User    restricted    to    add    permission    is    given    link    to    change    list    view    in    breadcrumbs.')
    post = self.client.post('/test_admin/admin/admin_views/article/add/', add_dict)
    self.assertRedirects(post, '/test_admin/admin/')
    self.assertEqual(Article.objects.all().count(), 4)
    self.assertEqual(len(mail.outbox), 1)
    self.assertEqual(mail.outbox[0].subject, 'Greetings    from    a    created    object')
    self.client.get('/test_admin/admin/logout/')
    self.client.get('/test_admin/admin/')
    self.client.post('/test_admin/admin/', self.super_login)
    addpage = self.client.get('/test_admin/admin/admin_views/article/add/')
    self.assertEqual(addpage.status_code, 200)
    self.assertFalse((change_list_link not in addpage.content), 'Unrestricted    user    is    not    given    link    to    change    list    view    in    breadcrumbs.')
    post = self.client.post('/test_admin/admin/admin_views/article/add/', add_dict)
    self.assertRedirects(post, '/test_admin/admin/admin_views/article/')
    self.assertEqual(Article.objects.all().count(), 5)
    self.client.get('/test_admin/admin/logout/')
    login = self.client.login(username='joepublic', password='secret')
    self.client.get('/test_admin/admin/')
    self.client.post('/test_admin/admin/', self.super_login)
    self.assertEqual(self.client.session.test_cookie_worked(), False)
