Skip to content

Instantly share code, notes, and snippets.

@solidpple
Created December 18, 2017 12:22
Show Gist options
  • Save solidpple/e56f7e3db8a54d61f18826b295ba9e17 to your computer and use it in GitHub Desktop.
Save solidpple/e56f7e3db8a54d61f18826b295ba9e17 to your computer and use it in GitHub Desktop.
import datetime
from django.utils import timezone
from django.test import TestCase
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment