コード例 #1
0
 def test_was_published_recently_with_old_question(self):
     """
     was_published_recently() should return False for an old question, older that 1 day old
     """
     in_the_past = timezone.now() - datetime.timedelta(days=2)
     q = Question(pub_date=in_the_past, question_text="anything")
     self.assertIs(q.was_published_recently(), False)
コード例 #2
0
 def test_was_published_recently_with_future_question(self):
     """
     was_published_recently() returns False for questions whose pub_date is in the future
     """
     in_the_future = timezone.now() + datetime.timedelta(days=30)
     q = Question(pub_date=in_the_future, question_text="anything")
     self.assertIs(q.was_published_recently(), False)
コード例 #3
0
 def test_was_published_recently_with_recent_question(self):
     """
     was_published_recently() should return True for a question published within the last day
     """
     in_the_past = timezone.now() - datetime.timedelta(
         days=1) + datetime.timedelta(seconds=1)
     q = Question(pub_date=in_the_past, question_text="anything")
     self.assertIs(q.was_published_recently(), True)