Exemple #1
0
    def test_vote_creation_same_user(self):
        user1 = User.objects.create_user(username="******")
        vote_type = VoteType.objects.create(type="+",
                                            sender_points=2,
                                            recipient_points=10)

        with self.assertRaises(
                ValidationError,
                msg="A self-vote did not raise exception as expected"):
            vote = Vote(sender=user1,
                        recipient=user1,
                        type=vote_type,
                        title=self.TEST_TITLE,
                        description=self.TEST_DESCRIPTION)
            vote.clean()
Exemple #2
0
 def validate(self, data):
     vote = Vote(**data)
     vote.clean()
     return data