本文整理汇总了Python中snippets.base.tests.SnippetFactory.refresh_from_db方法的典型用法代码示例。如果您正苦于以下问题:Python SnippetFactory.refresh_from_db方法的具体用法?Python SnippetFactory.refresh_from_db怎么用?Python SnippetFactory.refresh_from_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类snippets.base.tests.SnippetFactory
的用法示例。
在下文中一共展示了SnippetFactory.refresh_from_db方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_base
# 需要导入模块: from snippets.base.tests import SnippetFactory [as 别名]
# 或者: from snippets.base.tests.SnippetFactory import refresh_from_db [as 别名]
def test_base(self):
snippet_without_end_date = SnippetFactory(published=True, publish_end=None)
snippet_that_has_ended = SnippetFactory(published=True, publish_end=datetime.utcnow())
snippet_ending_in_the_future = SnippetFactory(
published=True, publish_end=datetime.utcnow() + timedelta(days=1))
call_command('disable_snippets_past_publish_date', stdout=Mock())
snippet_without_end_date.refresh_from_db()
snippet_that_has_ended.refresh_from_db()
snippet_ending_in_the_future.refresh_from_db()
self.assertFalse(snippet_that_has_ended.published)
self.assertTrue(snippet_without_end_date.published)
self.assertTrue(snippet_ending_in_the_future.published)
asrsnippet_without_end_date = ASRSnippetFactory(
status=STATUS_CHOICES['Published'],
publish_end=None)
asrsnippet_that_has_ended = ASRSnippetFactory(
status=STATUS_CHOICES['Published'],
publish_end=datetime.utcnow())
asrsnippet_ending_in_the_future = ASRSnippetFactory(
status=STATUS_CHOICES['Published'],
publish_end=datetime.utcnow() + timedelta(days=1))
call_command('disable_snippets_past_publish_date', stdout=Mock())
asrsnippet_without_end_date.refresh_from_db()
asrsnippet_that_has_ended.refresh_from_db()
asrsnippet_ending_in_the_future.refresh_from_db()
self.assertEqual(asrsnippet_that_has_ended.status, STATUS_CHOICES['Approved'])
self.assertEqual(asrsnippet_without_end_date.status, STATUS_CHOICES['Published'])
self.assertEqual(asrsnippet_ending_in_the_future.status, STATUS_CHOICES['Published'])