本文整理汇总了Python中models.Question.was_published_recently方法的典型用法代码示例。如果您正苦于以下问题:Python Question.was_published_recently方法的具体用法?Python Question.was_published_recently怎么用?Python Question.was_published_recently使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Question
的用法示例。
在下文中一共展示了Question.was_published_recently方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_was_published_recently_with_future_question
# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import was_published_recently [as 别名]
def test_was_published_recently_with_future_question(self):
"""
was_published_recently() should return False for questions whose pub_date is in the future.
"""
time = timezone.now() + datetime.timedelta(days=30)
future_question = Question(pub_date=time)
self.assertEqual(future_question.was_published_recently(), False)
示例2: test_was_published_recently_with_recent_question
# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import was_published_recently [as 别名]
def test_was_published_recently_with_recent_question(self):
"""
was_published_recently() should return True for questions whos pub_date is within the last day.
"""
time = timezone.now() + datetime.timedelta(hours=-1)
recent_question=Question(pub_date=time)
self.assertEqual(recent_question.was_published_recently(), True)
示例3: test_was_published_recently_wit_old_question
# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import was_published_recently [as 别名]
def test_was_published_recently_wit_old_question(self):
"""
was_published_recently() should return False for question whose pub_date is in within the last day
"""
time = timezone.now() + datetime.timedelta(days=-30)
old_question = Question(pub_date=time)
self.assertEqual(old_question.was_published_recently(), False)
示例4: test_was_published_recently_with_old_question
# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import was_published_recently [as 别名]
def test_was_published_recently_with_old_question(self):
"""
was_published_recently() should return False for questions whose
pub_date is older than 1 day.
"""
time = timezone.now() - datetime.timedelta(days=30)
old_question = Question(pub_date=time)
self.assertEqual(old_question.was_published_recently(), False)
示例5: test_was_published_recently_with_future_question
# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import was_published_recently [as 别名]
def test_was_published_recently_with_future_question(self):
time = timezone.now() + datetime.timedelta(days=30)
future_question = Question(pub_date=time)
self.assertEqual(future_question.was_published_recently(), False)
示例6: test_was_recently_published_with_recent_question
# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import was_published_recently [as 别名]
def test_was_recently_published_with_recent_question(self):
time = timezone.now() - datetime.timedelta(hours=1)
recent_question = Question(pub_date=time)
self.assertTrue(recent_question.was_published_recently())
示例7: test_was_recently_published_with_old_question
# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import was_published_recently [as 别名]
def test_was_recently_published_with_old_question(self):
time = timezone.now() - datetime.timedelta(days=30)
old_question = Question(pub_date=time)
self.assertFalse(old_question.was_published_recently())