def test_like_create(self): """ create like """ form_data = {} form = LikeForm(data=form_data) form.comment = self.comment form.user = self.user self.assertEqual(form.is_valid(), True)
def test_like_create_invalid(self): """ create like twice """ CommentLike.objects.create(user=self.user, comment=self.comment) form_data = {} form = LikeForm(data=form_data) form.comment = self.comment form.user = self.user self.assertEqual(form.is_valid(), False)