本文整理汇总了Python中tests.factories.CommentFactory.reload方法的典型用法代码示例。如果您正苦于以下问题:Python CommentFactory.reload方法的具体用法?Python CommentFactory.reload怎么用?Python CommentFactory.reload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.factories.CommentFactory
的用法示例。
在下文中一共展示了CommentFactory.reload方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestMigrateSpam
# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from tests.factories.CommentFactory import reload [as 别名]
class TestMigrateSpam(OsfTestCase):
def setUp(self):
super(TestMigrateSpam, self).setUp()
self.generic_report = {
'category': 'spam',
'text': 'spammer spam',
'date': datetime.utcnow(),
'retracted': False
}
Comment.remove()
self.user = AuthUserFactory()
self.comment_1 = CommentFactory()
self.comment_1.spam_status = 0
self.comment_1.reports[self.user._id] = self.generic_report
self.comment_1.save()
self.comment_2 = CommentFactory()
self.comment_2.spam_status = 0
self.comment_2.reports[self.user._id] = self.generic_report
self.comment_2.save()
self.comment_3 = CommentFactory()
self.comment_3.spam_status = 0
self.comment_3.save()
self.comment_4 = CommentFactory()
self.comment_4.date_last_reported = None
self.comment_4.spam_status = Comment.FLAGGED
self.comment_4.reports[self.user._id] = self.generic_report
self.comment_4.save()
self.comment_5 = CommentFactory()
self.comment_5.date_last_reported = None
self.comment_5.spam_status = Comment.UNKNOWN
self.comment_5.save()
self.comment_6 = CommentFactory()
self.comment_6.date_last_reported = None
self.comment_6.spam_status = Comment.SPAM
self.comment_6.reports[self.user._id] = self.generic_report
self.comment_6.save()
def test_get_status_targets(self):
targets = migrate_spam.get_no_status_targets()
nt.assert_equal(len(targets), 3)
def test_get_latest_targets(self):
migrate_spam.migrate_status(migrate_spam.get_no_status_targets())
targets = migrate_spam.get_no_latest_targets()
nt.assert_equal(len(targets), 4)
def test_migrate_status(self):
migrate_spam.migrate_status(migrate_spam.get_no_status_targets())
self.comment_2.reload()
self.comment_1.reload()
self.comment_3.reload()
nt.assert_equal(self.comment_1.spam_status, Comment.FLAGGED)
nt.assert_equal(self.comment_2.spam_status, Comment.FLAGGED)
nt.assert_equal(self.comment_3.spam_status, Comment.UNKNOWN)
def test_migrate_latest(self):
migrate_spam.migrate_status(migrate_spam.get_no_status_targets())
migrate_spam.migrate_latest(migrate_spam.get_no_latest_targets())
date = self.generic_report['date']
self.comment_4.reload()
self.comment_6.reload()
nt.assert_almost_equal(
self.comment_4.date_last_reported, date,
delta=timedelta(microseconds=1000)
)
nt.assert_almost_equal(
self.comment_6.date_last_reported, date,
delta=timedelta(microseconds=1000)
)
示例2: test_unmodified_comment_default_is_set_to_false
# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from tests.factories.CommentFactory import reload [as 别名]
def test_unmodified_comment_default_is_set_to_false(self):
comment = CommentFactory(modified=None)
do_migration(get_targets())
comment.reload()
assert_equal(comment.modified, False)