本文整理汇总了Python中tests.factories.CommentFactory.unreport_abuse方法的典型用法代码示例。如果您正苦于以下问题:Python CommentFactory.unreport_abuse方法的具体用法?Python CommentFactory.unreport_abuse怎么用?Python CommentFactory.unreport_abuse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.factories.CommentFactory
的用法示例。
在下文中一共展示了CommentFactory.unreport_abuse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestCommentModel
# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from tests.factories.CommentFactory import unreport_abuse [as 别名]
#.........这里部分代码省略.........
assert_equal(self.comment.content, 'edited')
assert_true(self.comment.modified)
assert_equal(len(self.comment.node.logs), 2)
assert_equal(self.comment.node.logs[-1].action, NodeLog.COMMENT_UPDATED)
def test_delete(self):
self.comment.delete(auth=self.auth, save=True)
assert_equal(self.comment.is_deleted, True)
assert_equal(len(self.comment.node.logs), 2)
assert_equal(self.comment.node.logs[-1].action, NodeLog.COMMENT_REMOVED)
def test_undelete(self):
self.comment.delete(auth=self.auth, save=True)
self.comment.undelete(auth=self.auth, save=True)
assert_equal(self.comment.is_deleted, False)
assert_equal(len(self.comment.node.logs), 3)
assert_equal(self.comment.node.logs[-1].action, NodeLog.COMMENT_RESTORED)
def test_report_abuse(self):
user = UserFactory()
self.comment.report_abuse(user, category='spam', text='ads', save=True)
assert_in(user._id, self.comment.reports)
assert_equal(
self.comment.reports[user._id],
{'category': 'spam', 'text': 'ads'}
)
def test_report_abuse_own_comment(self):
with assert_raises(ValueError):
self.comment.report_abuse(
self.comment.user, category='spam', text='ads', save=True
)
def test_unreport_abuse(self):
user = UserFactory()
self.comment.report_abuse(user, category='spam', text='ads', save=True)
self.comment.unreport_abuse(user, save=True)
assert_not_in(user._id, self.comment.reports)
def test_unreport_abuse_not_reporter(self):
reporter = UserFactory()
non_reporter = UserFactory()
self.comment.report_abuse(reporter, category='spam', text='ads', save=True)
with assert_raises(ValueError):
self.comment.unreport_abuse(non_reporter, save=True)
assert_in(reporter._id, self.comment.reports)
def test_validate_reports_bad_key(self):
self.comment.reports[None] = {'category': 'spam', 'text': 'ads'}
with assert_raises(ValidationValueError):
self.comment.save()
def test_validate_reports_bad_type(self):
self.comment.reports[self.comment.user._id] = 'not a dict'
with assert_raises(ValidationTypeError):
self.comment.save()
def test_validate_reports_bad_value(self):
self.comment.reports[self.comment.user._id] = {'foo': 'bar'}
with assert_raises(ValidationValueError):
self.comment.save()
def test_read_permission_contributor_can_comment(self):
project = ProjectFactory()
user = UserFactory()
project.set_privacy('private')