def test_vote(self): """ vote() receives a choice, ups the votes integer for the choice and adds a vote record """ time = timezone.now() - datetime.timedelta(days=10) past_question = Question.objects.create(pub_date=time, question_text="How are you?") choice = Choice.objects.create(question=past_question, choice_text="Awesome") # TODO: figure out if there is a better way to assert changes self.assertIs(choice.votes.count(), 0) self.assertIs(Vote.objects.count(), 0) user = AnonymousUser() vote = user.vote(choice) self.assertIs(choice.vote_count, 1) self.assertIs(choice.votes.count(), 1) self.assertIs(Vote.objects.count(), 1) self.assertIs(vote.choice, choice)