当前位置: 首页>>代码示例>>Python>>正文


Python CommentFactory.reload方法代码示例

本文整理汇总了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)
        )
开发者ID:545zhou,项目名称:osf.io,代码行数:71,代码来源:test_migrate_spam.py

示例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)
开发者ID:545zhou,项目名称:osf.io,代码行数:7,代码来源:test_set_comment_modified_default_false.py


注:本文中的tests.factories.CommentFactory.reload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。