Skip to content

Commit

Permalink
was_published_recently is covered by test
Browse files Browse the repository at this point in the history
  • Loading branch information
ale7canna committed Jun 17, 2020
1 parent 2ae606e commit 7ae02f7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions polls/tests.py
Expand Up @@ -13,3 +13,17 @@ def test_was_published_recently_with_future_question(self):
future_question = Question(pub_date=time)

self.assertIs(future_question.was_published_recently(), False)

def test_was_published_recently_with_old_question(self):
"""was_published_recently returns False with questions older than 1 day"""
time = timezone.now() - datetime.timedelta(days=1, seconds=1)
old_question = Question(pub_date=time)

self.assertIs(old_question.was_published_recently(), False)

def test_was_published_recently_with_recent_question(self):
"""was_published_recently returns True with questions whose pub_date is within the last day"""
time = timezone.now() - datetime.timedelta(hours=23, minutes=59, seconds=59)
old_question = Question(pub_date=time)

self.assertIs(old_question.was_published_recently(), True)

0 comments on commit 7ae02f7

Please sign in to comment.