

def testPostAsAuthenticatedUser(self):
    a = Article.objects.get(pk=1)
    data = self.getValidData(a)
    data['name'] = data['email'] = ''
    self.client.login(username='normaluser', password='normaluser')
    self.response = self.client.post('/post/', data, REMOTE_ADDR='1.2.3.4')
    self.assertEqual(self.response.status_code, 302)
    self.assertEqual(Comment.objects.count(), 1)
    c = Comment.objects.all()[0]
    self.assertEqual(c.ip_address, '1.2.3.4')
    u = User.objects.get(username='normaluser')
    self.assertEqual(c.user, u)
    self.assertEqual(c.user_name, u.get_full_name())
    self.assertEqual(c.user_email, u.email)

dataset/ETHPy150Open dcramer/django-compositepks/tests/regressiontests/comment_tests/tests/comment_view_tests.py CommentViewTests.testPostAsAuthenticatedUser/original