Esempio n. 1
0
 def test_cannot_validate_empty_votes(self):
     # Setup
     form_data = {}
     # Run
     form = TopicPollVoteForm(data=form_data, poll=self.poll)
     valid = form.is_valid()
     # Check
     assert not valid
Esempio n. 2
0
 def test_can_valid_a_basic_vote(self):
     # Setup
     form_data = {
         'options': self.option_1.pk,
     }
     # Run
     form = TopicPollVoteForm(data=form_data, poll=self.poll)
     valid = form.is_valid()
     # Check
     assert valid
Esempio n. 3
0
 def test_cannot_validate_empty_votes(self):
     # Setup
     form_data = {}
     # Run
     form = TopicPollVoteForm(
         data=form_data,
         poll=self.poll)
     valid = form.is_valid()
     # Check
     assert not valid
Esempio n. 4
0
 def test_can_valid_a_basic_vote(self):
     # Setup
     form_data = {
         'options': self.option_1.pk,
     }
     # Run
     form = TopicPollVoteForm(
         data=form_data,
         poll=self.poll)
     valid = form.is_valid()
     # Check
     assert valid
Esempio n. 5
0
 def test_cannot_validate_votes_for_too_many_options(self):
     # Setup
     self.poll.max_options = 3
     self.poll.save()
     option_3 = TopicPollOptionFactory.create(poll=self.poll)
     option_4 = TopicPollOptionFactory.create(poll=self.poll)
     form_data = {
         'options': [self.option_1.pk, self.option_2.pk, option_3.pk, option_4.pk, ]
     }
     # Run
     form = TopicPollVoteForm(
         data=form_data,
         poll=self.poll)
     valid = form.is_valid()
     # Check
     assert not valid