part 5 - tests

This commit is contained in:
Josh Flatt 2025-11-22 21:16:06 -06:00
parent 2fcbc9cffb
commit 8a1d8b8ccf

View File

@ -1,3 +1,17 @@
from django.test import TestCase import datetime
# Create your tests here. from django.test import TestCase
from django.utils import timezone
from .models import Question
class QuestionModelTests(TestCase):
def test_was_published_recently_with_future_question(self):
"""
was_published_recently() returns False for questions whose pub_date
is in the future.
"""
time = timezone.now() + datetime.timedelta(days=30)
future_question = Question(pub_date=time)
self.assertIs(future_question.was_published_recently(), False)