def test_create_a_poll_and_save_it_to_the_database(self): poll = Poll() poll.question = self.options.get('question') poll.created_at = self.options.get('created_at') poll.save() polls_list = Poll.objects.all() self.assertEquals(len(polls_list), 1) current_poll = polls_list[0] self.assertEquals(current_poll, poll) self.assertEquals(current_poll.question, self.options.get('question'))
def test_create_poll_choices(self): poll = Poll() poll.question = self.options.get('question') poll.created_at = self.options.get('created_at') poll.save() choice = Choice() choice.poll = poll choice.choice = self.options.get('choice') choice.votes = self.options.get('votes') choice.save() poll_choices = poll.choice_set.all() self.assertEquals(poll_choices.count(), 1) choice_from_db = poll_choices[0] self.assertEquals(choice_from_db, choice) self.assertEquals(choice_from_db.choice, self.options.get('choice')) self.assertEquals(choice_from_db.votes, self.options.get('votes'))