Ejemplo n.º 1
0
 def testUserManipulationOnCreateFails(self):
     self.assertEqual(0,
                      Vote.objects.filter(user=self.correct_user).count())
     self.assertEqual(0, Vote.objects.filter(user=self.wrong_user).count())
     form = VoteForm(initial={'user': self.correct_user},
                     data={
                         'user': self.wrong_user.id,
                         'movie': self.movie.id,
                         'value': Vote.UP
                     })
     self.assertFalse(form.is_valid())
Ejemplo n.º 2
0
 def testVoteCreatedWithGoodData(self):
     self.assertEqual(0,
                      Vote.objects.filter(user=self.correct_user).count())
     self.assertEqual(0, Vote.objects.filter(user=self.wrong_user).count())
     form = VoteForm(initial={
         'user': self.correct_user.id,
         'movie': self.movie.id,
     },
                     data={'value': Vote.UP})
     self.assertTrue(form.is_valid(), form.errors)
     form.save()
     self.assertEqual(1,
                      Vote.objects.filter(user=self.correct_user).count())
     self.assertEqual(0, Vote.objects.filter(user=self.wrong_user).count())