Exemple #1
0
    def test_GET_on_day_with_no_questions(self):
        response = DailyQuestionList.as_view()(self.REQUEST,
                                               year=self.today.year,
                                               month=self.today.month,
                                               day=self.today.day)

        self.assertEqual(200, response.status_code)
        self.assertEqual(['qanda/question_archive_day.html'],
                         response.template_name)
        self.assertEqual(0, response.context_data['object_list'].count())
        self.assertContains(
            response, 'Hmmm.....Everyone thins they know everything today')
Exemple #2
0
    def test_GET_on_day_with_many_questions(self):
        todays_questions = [QuestionFactory() for _ in range(10)]
        response = DailyQuestionList.as_view()(self.REQUEST,
                                               year=self.TODAY.year,
                                               month=self.TODAY.month,
                                               day=self.TODAY.day)

        self.assertEqual(200, response.status_code)
        self.assertEqual(10, response.context_data['object_list'].count())
        rendered_content = response.rendered_content
        for question in todays_questions:
            needle = self.QUESTION_LIST_NEEDLE_TEMPLATE.format(
                id=question.id,
                title=question.title,
                username=question.user.username,
                date=question.created.strftime(QUESTION_CREATED_STRFTIME))
            self.assertInHTML(needle, rendered_content)